-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
feat: optimize method to determine whether the two path are the same in ensureUrl methods #3477
base: dev
Are you sure you want to change the base?
Changes from 3 commits
22a0f46
4b9e386
32d24a3
39c6863
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import type VueRouter from '../index' | ||
import { stringifyQuery } from './query' | ||
import { normalizeLocation } from './location' | ||
|
||
const trailingSlashRE = /\/?$/ | ||
|
||
|
@@ -96,8 +97,8 @@ export function isSameRoute (a: Route, b: ?Route): boolean { | |
function isObjectEqual (a = {}, b = {}): boolean { | ||
// handle null value #1566 | ||
if (!a || !b) return a === b | ||
const aKeys = Object.keys(a).sort() | ||
const bKeys = Object.keys(b).sort() | ||
const aKeys = Object.keys(a) | ||
const bKeys = Object.keys(b) | ||
if (aKeys.length !== bKeys.length) { | ||
return false | ||
} | ||
|
@@ -149,3 +150,8 @@ export function handleRouteEntered (route: Route) { | |
} | ||
} | ||
} | ||
/** just create a route without any added process */ | ||
export function createPlainRoute (url: string): Route { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 call There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
const location = normalizeLocation(url) | ||
return createRoute(null, location) | ||
} |
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.
Why should this be removed?
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.
if that not be removed, they are the same object as below:
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.
the "ensureURL " method will not go into 'if ' block in this scene.