@tanstack/react-router
Advanced tools
Comparing version 1.39.4 to 1.39.6
@@ -148,3 +148,16 @@ import { last } from "./utils.js"; | ||
function removeBasepath(basepath, pathname) { | ||
return basepath != "/" ? pathname.replace(basepath, "") : pathname; | ||
switch (true) { | ||
case basepath === "/": | ||
return pathname; | ||
case pathname === basepath: | ||
return ""; | ||
case pathname.length < basepath.length: | ||
return pathname; | ||
case pathname[basepath.length] !== "/": | ||
return pathname; | ||
case pathname.startsWith(basepath): | ||
return pathname.slice(basepath.length); | ||
default: | ||
return pathname; | ||
} | ||
} | ||
@@ -151,0 +164,0 @@ function matchByPath(basepath, from, matchLocation) { |
{ | ||
"name": "@tanstack/react-router", | ||
"version": "1.39.4", | ||
"version": "1.39.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -85,2 +85,3 @@ import { last } from './utils' | ||
} | ||
export function resolvePath({ | ||
@@ -200,2 +201,3 @@ basepath, | ||
} | ||
export function interpolatePath({ | ||
@@ -246,3 +248,32 @@ path, | ||
export function removeBasepath(basepath: string, pathname: string) { | ||
return basepath != '/' ? pathname.replace(basepath, '') : pathname | ||
switch (true) { | ||
// default behaviour is to serve app from the root - pathname | ||
// left untouched | ||
case basepath === '/': | ||
return pathname | ||
// shortcut for removing the basepath from the equal pathname | ||
case pathname === basepath: | ||
return '' | ||
// in case pathname is shorter than basepath - there is | ||
// nothing to remove | ||
case pathname.length < basepath.length: | ||
return pathname | ||
// avoid matching partial segments - strict equality handled | ||
// earlier, otherwise, basepath separated from pathname with | ||
// separator, therefore lack of separator means partial | ||
// segment match (`/app` should not match `/application`) | ||
case pathname[basepath.length] !== '/': | ||
return pathname | ||
// remove the basepath from the pathname in case there is any | ||
case pathname.startsWith(basepath): | ||
return pathname.slice(basepath.length) | ||
// otherwise, return the pathname as is | ||
default: | ||
return pathname | ||
} | ||
} | ||
@@ -249,0 +280,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1381715
16930