-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We should skip the same URL #317
Conversation
@xiaohulu Thank you, do you mind adding a unit test for the change? |
Codecov Report
@@ Coverage Diff @@
## master #317 +/- ##
==========================================
- Coverage 97.2% 97.18% -0.02%
==========================================
Files 99 99
Lines 5365 5367 +2
Branches 1202 1203 +1
==========================================
+ Hits 5215 5216 +1
- Misses 150 151 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #317 +/- ##
==========================================
+ Coverage 97.2% 97.25% +0.05%
==========================================
Files 99 100 +1
Lines 5365 5397 +32
Branches 1202 1213 +11
==========================================
+ Hits 5215 5249 +34
+ Misses 150 148 -2
Continue to review full report at Codecov.
|
I do not know how to run I write the unit test code here, I do not know if it can pass. it('update path, skip the same path', () => {
const history = new StateHistory({ onChange, window: sandbox.contentWindow! });
history.set('foo');
history.set('bar');
history.set('bar');
sandbox.contentWindow!.history.back();
assert.equal(history.current, '/foo');
assert.equal(sandbox.contentWindow!.location.pathname, '/foo');
}); |
@xiaohulu Hmmm that's interesting, I seem to be able to run the tests (on mac, node: v8.9.1 and npm: 6.4.1). Have you tried, removing and reinstalling node_modules (and removing the package-lock too)? |
src/routing/history/StateHistory.ts
Outdated
@@ -53,6 +53,9 @@ export class StateHistory implements HistoryInterface { | |||
} | |||
|
|||
public set(path: string) { | |||
if (path === this._window.location.pathname) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiaohulu Do you think we should move the logic from _onChange
that does a check against the current and previous value to set
function?
const pathName = this._window.location.pathname.replace(/\/$/, '');
const value = stripBase(this._base, pathName + this._window.location.search);
if (this._current === value) {
return;
}
…nd previous value to set function
@agubler What is the |
@xiaohulu Thanks! |
Type: bug
The following has been addressed in the PR:
prettier
as per the readme code style guidelinesDescription:
I use
Link
widget to navigate, but If I click the sameLink
n times, I must click Back button n times to back to previous route. We should skip the same url.