Skip to content

Commit 2bf3314

Browse files
committed
use original PushRelativePathnameWarning test
1 parent f595287 commit 2bf3314

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/history/__tests__/TestSequences/PushRelativePathnameWarning.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export default (history, done) => {
2323

2424
history.push('../other/path?another=query#another-hash');
2525

26-
expect(spy).toHaveBeenCalled();
26+
expect(spy).toHaveBeenCalledWith(
27+
expect.stringContaining('relative pathnames are not supported')
28+
);
2729

2830
destroy();
2931
},

packages/history/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,6 @@ export function createHashHistory(
599599
return parsePath(pathname.replace('/', hashRoot));
600600
}
601601

602-
function validateLocation({pathname}) {
603-
return pathname === parsePathOutput(pathname)
604-
}
605-
606602
function getIndexAndLocation(): [number, Location] {
607603
let {
608604
pathname = '/',
@@ -752,8 +748,8 @@ export function createHashHistory(
752748
}
753749

754750
warning(
755-
validateLocation(nextLocation),
756-
`Locations must start with "${hashRoot}" in hash history.push(${JSON.stringify(
751+
nextLocation.pathname.charAt(0) === '/',
752+
`Relative pathnames are not supported in hash history.push(${JSON.stringify(
757753
to
758754
)})`
759755
);
@@ -783,8 +779,8 @@ export function createHashHistory(
783779
}
784780

785781
warning(
786-
validateLocation(nextLocation),
787-
`Locations must start with "${hashRoot}" in hash history.replace(${JSON.stringify(
782+
nextLocation.pathname.charAt(0) === '/',
783+
`Relative pathnames are not supported in hash history.replace(${JSON.stringify(
788784
to
789785
)})`
790786
);

0 commit comments

Comments
 (0)