// location.pathname contains an initial `/` even at the root: `https://example.com`
base = location.host ? base || location.pathname + location.search : ''
// allow the user to provide a `#` in the middle: `/base/#/app`
- if (base.indexOf('#') < 0) base += '#'
+ if (!base.includes('#')) base += '#'
if (__DEV__ && !base.endsWith('#/') && !base.endsWith('#')) {
warn(
*/
export function stripBase(pathname: string, base: string): string {
// no base or base is not found at the beginning
- if (!base || pathname.toLowerCase().indexOf(base.toLowerCase()))
+ if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase()))
return pathname
return pathname.slice(base.length) || '/'
}
if (typeof newTargetLocation === 'string') {
newTargetLocation =
- newTargetLocation.indexOf('?') > -1 ||
- newTargetLocation.indexOf('#') > -1
+ newTargetLocation.includes('?') || newTargetLocation.includes('#')
? (newTargetLocation = locationAsObject(newTargetLocation))
: // force empty params
{ path: newTargetLocation }
guards = []
for (const record of to.matched) {
// do not trigger beforeEnter on reused views
- if (record.beforeEnter && from.matched.indexOf(record as any) < 0) {
+ if (record.beforeEnter && !from.matched.includes(record as any)) {
if (Array.isArray(record.beforeEnter)) {
for (const beforeEnter of record.beforeEnter)
guards.push(guardToPromiseFn(beforeEnter, to, from))