MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / removePrefix

Function removePrefix

core/src/components/router/utils/path.ts:76–92  ·  view source on GitHub ↗
(prefix: string[], segments: string[])

Source from the content-addressed store, hash-verified

74 * - the path segments after the prefix otherwise.
75 */
76const removePrefix = (prefix: string[], segments: string[]): string[] | null => {
77 if (prefix.length > segments.length) {
78 return null;
79 }
80 if (prefix.length <= 1 && prefix[0] === '') {
81 return segments;
82 }
83 for (let i = 0; i < prefix.length; i++) {
84 if (prefix[i] !== segments[i]) {
85 return null;
86 }
87 }
88 if (segments.length === prefix.length) {
89 return [''];
90 }
91 return segments.slice(prefix.length);
92};
93
94export const readSegments = (loc: Location, root: string, useHash: boolean): string[] | null => {
95 const prefix = parsePath(root).segments;

Callers 1

readSegmentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected