-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow absolute urls in router and Link (#15792)
- Loading branch information
Showing
15 changed files
with
367 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 20 additions & 7 deletions
27
packages/next/next-server/lib/router/utils/parse-relative-url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
export async function getServerSideProps({ query: { port } }) { | ||
if (!port) { | ||
throw new Error('port required') | ||
} | ||
return { props: { port } } | ||
} | ||
|
||
export default function Page({ port }) { | ||
return ( | ||
<> | ||
<Link href={`http://localhost:${port}/docs/something-else`}> | ||
<a id="absolute-link">http://localhost:{port}/docs/something-else</a> | ||
</Link> | ||
</> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
test/integration/basepath/pages/absolute-url-no-basepath.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
export async function getServerSideProps({ query: { port } }) { | ||
if (!port) { | ||
throw new Error('port required') | ||
} | ||
return { props: { port } } | ||
} | ||
|
||
export default function Page({ port }) { | ||
return ( | ||
<> | ||
<Link href={`http://localhost:${port}/rewrite-no-basepath`}> | ||
<a id="absolute-link">http://localhost:{port}/rewrite-no-basepath</a> | ||
</Link> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<Link href="https://vercel.com/"> | ||
<a id="absolute-link">https://vercel.com/</a> | ||
</Link> | ||
<br /> | ||
<Link href="mailto:idk@idk.com"> | ||
<a id="mailto-link">mailto:idk@idk.com</a> | ||
</Link> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.