Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
764b1945
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
764b1945
编写于
9月 03, 2020
作者:
J
Jan Potoms
提交者:
GitHub
9月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make parseRelativeUrl return a UrlObject (#16809)
Alternative to
https://github.com/vercel/next.js/pull/16798
上级
0e843e60
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
5 addition
and
14 deletion
+5
-14
packages/next/client/page-loader.ts
packages/next/client/page-loader.ts
+1
-5
packages/next/next-server/lib/router/router.ts
packages/next/next-server/lib/router/router.ts
+1
-3
packages/next/next-server/lib/router/utils/parse-relative-url.ts
...s/next/next-server/lib/router/utils/parse-relative-url.ts
+2
-1
packages/next/next-server/lib/router/utils/prepare-destination.ts
.../next/next-server/lib/router/utils/prepare-destination.ts
+1
-5
未找到文件。
packages/next/client/page-loader.ts
浏览文件 @
764b1945
...
...
@@ -12,7 +12,6 @@ import {
import
getAssetPathFromRoute
from
'
../next-server/lib/router/utils/get-asset-path-from-route
'
import
{
isDynamicRoute
}
from
'
../next-server/lib/router/utils/is-dynamic
'
import
{
parseRelativeUrl
}
from
'
../next-server/lib/router/utils/parse-relative-url
'
import
{
searchParamsToUrlQuery
}
from
'
../next-server/lib/router/utils/querystring
'
export
const
looseToArray
=
<
T
extends
{}
>
(
input
:
any
):
T
[]
=>
[].
slice
.
call
(
input
)
...
...
@@ -204,10 +203,7 @@ export default class PageLoader {
* @param {string} asPath the URL as shown in browser (virtual path); used for dynamic routes
*/
getDataHref
(
href
:
string
,
asPath
:
string
,
ssg
:
boolean
)
{
const
{
pathname
:
hrefPathname
,
searchParams
,
search
}
=
parseRelativeUrl
(
href
)
const
query
=
searchParamsToUrlQuery
(
searchParams
)
const
{
pathname
:
hrefPathname
,
query
,
search
}
=
parseRelativeUrl
(
href
)
const
{
pathname
:
asPathname
}
=
parseRelativeUrl
(
asPath
)
const
route
=
normalizeRoute
(
hrefPathname
)
...
...
packages/next/next-server/lib/router/router.ts
浏览文件 @
764b1945
...
...
@@ -563,7 +563,7 @@ export default class Router implements BaseRouter {
let
parsed
=
parseRelativeUrl
(
url
)
let
{
pathname
,
searchParams
}
=
parsed
let
{
pathname
,
query
}
=
parsed
parsed
=
this
.
_resolveHref
(
parsed
,
pages
)
as
typeof
parsed
...
...
@@ -572,8 +572,6 @@ export default class Router implements BaseRouter {
url
=
formatWithValidation
(
parsed
)
}
const
query
=
searchParamsToUrlQuery
(
searchParams
)
// url and as should always be prefixed with basePath by this
// point by either next/link or router.push/replace so strip the
// basePath from the pathname to match the pages dir 1-to-1
...
...
packages/next/next-server/lib/router/utils/parse-relative-url.ts
浏览文件 @
764b1945
import
{
getLocationOrigin
}
from
'
../../utils
'
import
{
searchParamsToUrlQuery
}
from
'
./querystring
'
const
DUMMY_BASE
=
new
URL
(
typeof
window
===
'
undefined
'
?
'
http://n
'
:
getLocationOrigin
()
...
...
@@ -29,7 +30,7 @@ export function parseRelativeUrl(url: string, base?: string) {
}
return
{
pathname
,
searchParams
,
query
:
searchParamsToUrlQuery
(
searchParams
)
,
search
,
hash
,
href
:
href
.
slice
(
DUMMY_BASE
.
origin
.
length
),
...
...
packages/next/next-server/lib/router/utils/prepare-destination.ts
浏览文件 @
764b1945
...
...
@@ -35,7 +35,7 @@ export default function prepareDestination(
parsedDestination
=
{
pathname
,
searchParams
,
query
:
searchParamsToUrlQuery
(
searchParams
)
,
hash
,
protocol
,
hostname
,
...
...
@@ -45,9 +45,6 @@ export default function prepareDestination(
}
}
parsedDestination
.
query
=
searchParamsToUrlQuery
(
parsedDestination
.
searchParams
)
const
destQuery
=
parsedDestination
.
query
const
destPath
=
`
${
parsedDestination
.
pathname
!
}${
parsedDestination
.
hash
||
''
...
...
@@ -108,7 +105,6 @@ export default function prepareDestination(
parsedDestination
.
pathname
=
pathname
parsedDestination
.
hash
=
`
${
hash
?
'
#
'
:
''
}${
hash
||
''
}
`
delete
parsedDestination
.
search
delete
parsedDestination
.
searchParams
}
catch
(
err
)
{
if
(
err
.
message
.
match
(
/Expected .*
?
to not repeat, but got an array/
))
{
throw
new
Error
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录