Skip to content

Commit

Permalink
Warn when path does not contain basename (#453)
Browse files Browse the repository at this point in the history
This is only a problem when getting the path from the URL.
  • Loading branch information
pshrmn authored and mjackson committed Apr 20, 2017
1 parent a647c5d commit fbf5f47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/createBrowserHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ const createBrowserHistory = (props = {}) => {

let path = pathname + search + hash

warning(
!(basename && path.indexOf(basename) !== 0),
'You are attempting to use a basename on a page whose URL path does not begin ' +
'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'
)

if (basename)
path = stripPrefix(path, basename)

Expand Down
6 changes: 6 additions & 0 deletions modules/createHashHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ const createHashHistory = (props = {}) => {
const getDOMLocation = () => {
let path = decodePath(getHashPath())

warning(
!(basename && path.indexOf(basename) !== 0),
'You are attempting to use a basename on a page whose URL path does not begin ' +
'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'
)

if (basename)
path = stripPrefix(path, basename)

Expand Down

0 comments on commit fbf5f47

Please sign in to comment.