Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: optimize method to determine whether the two path are the same in ensureUrl methods#3477

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
wxwzl wants to merge4 commits intovuejs:dev
base:dev
Choose a base branch
Loading
fromwxwzl:dev

Conversation

wxwzl
Copy link

Fix#3447 , optimize method to determine whether the two path are the same in ensureUrl methods

Copy link
Member

@posvaposva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you add e2e tests for both hash and html5 history as well?

const aKeys = Object.keys(a).sort()
const bKeys = Object.keys(b).sort()
const aKeys = Object.keys(a)
const bKeys = Object.keys(b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why should this be removed?

Copy link
Author

@wxwzlwxwzlMay 25, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

if that not be removed, they are the same object as below:

var a = {a:1,b:2}; var b = {b:2,a:1};

Object.keys method will keep the order of attributes in an object as the attributes were added.

if that not be removed, "https://vesaas.com/?a=1&b=2" and "https://vesaas.com/?b=2&a=1" will be thought the same route.

  ensureURL (push?: boolean) {    const location = getHash()    const plainRoute = createPlainRoute(location)    if (!isSameRoute(plainRoute, this.current)) {      const current = this.current.fullPath      push ? pushHash(current) : replaceHash(current)    }  }

the "ensureURL " method will not go into 'if ' block in this scene.

@@ -149,3 +150,8 @@ export function handleRouteEntered (route: Route) {
}
}
}
/** just create a route without any added process */
export function createPlainRoute (url: string): Route {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ideally, this function (and its tests) should be removed since we just need to callnormalizeLocation() on the url and compare it withthis.current

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

but how to compare with this current ,this.current is a Route object.I thought if it turn to a Route object , the logic can be keep smooth and complete.

@wxwzl
Copy link
Author

Can you add e2e tests for both hash and html5 history as well?

I try my best to do it.

@wxwzlwxwzl requested a review fromposvaMay 30, 2021 07:29
@mmeester
Copy link

upvote 👍

@mmeester
Copy link

I've just tried the fix by@wxwzl but as far as I can determine this isn't fixing the issue that query params are sorted on init.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mmeestermmeestermmeester approved these changes

@danielgroendanielgroendanielgroen approved these changes

@posvaposvaAwaiting requested review from posva

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Why is it designed as below? it will cause history.replaceState method to be called
5 participants
@wxwzl@mmeester@posva@danielgroen@vinezhang

[8]ページ先頭

©2009-2025 Movatter.jp