Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/canary' into add/gssp-redirect…
Browse files Browse the repository at this point in the history
…-handling
  • Loading branch information
ijjk committed Aug 28, 2020
2 parents ed7beaf + 20a4928 commit f730244
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/basic-features/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Next.js will automatically configure this file with default values. Providing yo

> Next.js uses Babel to handle TypeScript, which has some [caveats](https://babeljs.io/docs/en/babel-plugin-transform-typescript#caveats), and some [compiler options are handled differently](https://babeljs.io/docs/en/babel-plugin-transform-typescript#typescript-compiler-options).
Then, run `next` (normally `npm run dev`) and Next.js will guide you through the installation of the required packages to finish the setup:
Then, run `next` (normally `npm run dev` or `yarn dev`) and Next.js will guide you through the installation of the required packages to finish the setup:

```bash
npm run dev
Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Install `next`, `react` and `react-dom` in your project:

```bash
npm install next react react-dom
# or
yarn add next react react-dom
```

Open `package.json` and add the following `scripts`:
Expand Down Expand Up @@ -71,7 +73,7 @@ function HomePage() {
export default HomePage
```

To start developing your application run `npm run dev`. This starts the development server on `http://localhost:3000`.
To start developing your application run `npm run dev` or `yarn dev`. This starts the development server on `http://localhost:3000`.

Visit `http://localhost:3000` to view your application.

Expand Down
25 changes: 2 additions & 23 deletions packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,6 @@ function prepareUrlAs(router: NextRouter, url: Url, as: Url) {
}
}

function tryParseRelativeUrl(
url: string
): null | ReturnType<typeof parseRelativeUrl> {
try {
return parseRelativeUrl(url)
} catch (err) {
if (process.env.NODE_ENV !== 'production') {
setTimeout(() => {
throw new Error(
`Invalid href passed to router: ${url} https://err.sh/vercel/next.js/invalid-href-passed`
)
}, 0)
}
return null
}
}

export type BaseRouter = {
route: string
pathname: string
Expand Down Expand Up @@ -503,9 +486,7 @@ export default class Router implements BaseRouter {
const pages = await this.pageLoader.getPageList()
const { __rewrites: rewrites } = await this.pageLoader.promisedBuildManifest

let parsed = tryParseRelativeUrl(url)

if (!parsed) return false
let parsed = parseRelativeUrl(url)

let { pathname, searchParams } = parsed

Expand Down Expand Up @@ -930,9 +911,7 @@ export default class Router implements BaseRouter {
asPath: string = url,
options: PrefetchOptions = {}
): Promise<void> {
let parsed = tryParseRelativeUrl(url)

if (!parsed) return
let parsed = parseRelativeUrl(url)

let { pathname } = parsed

Expand Down
6 changes: 6 additions & 0 deletions test/integration/invalid-href/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ describe('Invalid hrefs', () => {
const $ = cheerio.load(await res.text())
expect($('#click-me').attr('href')).toBe('https://')
})

it('renders a link with mailto: href', async () => {
const res = await fetchViaHTTP(appPort, '/first')
const $ = cheerio.load(await res.text())
expect($('#click-me').attr('href')).toBe('mailto:idk@idk.com')
})
})

describe('dev mode', () => {
Expand Down

0 comments on commit f730244

Please sign in to comment.