@pinnacle0/react-stack-router
Advanced tools
Comparing version 0.1.3-beta.0 to 0.1.3-beta.1
@@ -35,3 +35,4 @@ export interface RouteNode<T> { | ||
} | ||
export declare function pathToSegments(path: string): string[]; | ||
export declare function formatPath(path: string): string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -11,4 +11,3 @@ import { invariant } from "../invariant"; | ||
this.cache.clear(); | ||
const formattedPath = formatPath(path); | ||
const segments = formattedPath === "/" ? ["/"] : formattedPath.split("/"); | ||
const segments = pathToSegments(path); | ||
let currentNode = this.root; | ||
@@ -40,4 +39,3 @@ for (const segment of segments) { | ||
freshLookup(path) { | ||
const formattedPath = formatPath(path); | ||
const segments = formattedPath === "/" ? ["/"] : formattedPath.split("/"); | ||
const segments = pathToSegments(path); | ||
let params = {}; | ||
@@ -113,2 +111,12 @@ let nextNode = this.root; | ||
} | ||
export function pathToSegments(path) { | ||
let formattedPath = formatPath(path); | ||
const segments = []; | ||
if (formattedPath.startsWith("/")) { | ||
segments.push("/"); | ||
formattedPath = formattedPath.substring(1); | ||
} | ||
formattedPath.split("/").forEach(_ => _.length > 0 && segments.push(_)); | ||
return segments; | ||
} | ||
export function formatPath(path) { | ||
@@ -122,8 +130,4 @@ let formatted = path.replaceAll(/[/]+/g, "/"); | ||
} | ||
// removed leading '/' | ||
if (formatted[0] === "/") { | ||
formatted = formatted.slice(1); | ||
} | ||
return formatted; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@pinnacle0/react-stack-router", | ||
"version": "0.1.3-beta.0", | ||
"version": "0.1.3-beta.1", | ||
"author": "Pinnacle", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -35,4 +35,3 @@ import {invariant} from "../invariant"; | ||
this.cache.clear(); | ||
const formattedPath = formatPath(path); | ||
const segments = formattedPath === "/" ? ["/"] : formattedPath.split("/"); | ||
const segments = pathToSegments(path); | ||
@@ -66,5 +65,4 @@ let currentNode: RouteNode<T> = this.root; | ||
private freshLookup(path: string): Match<T> | null { | ||
const formattedPath = formatPath(path); | ||
const segments = pathToSegments(path); | ||
const segments = formattedPath === "/" ? ["/"] : formattedPath.split("/"); | ||
let params: Record<string, string> = {}; | ||
@@ -146,2 +144,15 @@ let nextNode: RouteNode<T> = this.root; | ||
export function pathToSegments(path: string): string[] { | ||
let formattedPath = formatPath(path); | ||
const segments = []; | ||
if (formattedPath.startsWith("/")) { | ||
segments.push("/"); | ||
formattedPath = formattedPath.substring(1); | ||
} | ||
formattedPath.split("/").forEach(_ => _.length > 0 && segments.push(_)); | ||
return segments; | ||
} | ||
export function formatPath(path: string): string { | ||
@@ -157,8 +168,3 @@ let formatted = path.replaceAll(/[/]+/g, "/"); | ||
// removed leading '/' | ||
if (formatted[0] === "/") { | ||
formatted = formatted.slice(1); | ||
} | ||
return formatted; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
119155
2005
0