Unverified Commit 5248e182 authored by Fonger's avatar Fonger Committed by GitHub

fix(export): fallback to empty string for basePath (#11880)

* fix(next-server): fallback to empty string for basePath

* Revert extra change and add unit test
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent ab18c792
......@@ -16,7 +16,7 @@ import { isDynamicRoute } from './utils/is-dynamic'
import { getRouteMatcher } from './utils/route-matcher'
import { getRouteRegex } from './utils/route-regex'
const basePath = process.env.__NEXT_ROUTER_BASEPATH as string
const basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''
export function addBasePath(path: string): string {
return path.indexOf(basePath) !== 0 ? basePath + path : path
......
/* eslint-env jest */
import { addBasePath } from 'next/dist/next-server/lib/router/router'
describe('router addBasePath', () => {
it('should add basePath correctly when no basePath', () => {
const result = addBasePath('/hello')
expect(result).toBe('/hello')
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment