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

Function parsePath

core/src/components/router/utils/path.ts:107–138  ·  view source on GitHub ↗
(path: string | undefined | null)

Source from the content-addressed store, hash-verified

105 * - fragment (undefined when no `#`).
106 */
107export const parsePath = (path: string | undefined | null): ParsedRoute => {
108 let segments = [''];
109 let queryString;
110 let fragment;
111
112 if (path != null) {
113 // The fragment ("#") starts a section that runs to the end of the URL.
114 // Anything inside it (including "?") is part of the fragment per RFC 3986.
115 const fragStart = path.indexOf('#');
116 if (fragStart > -1) {
117 fragment = path.substring(fragStart + 1);
118 path = path.substring(0, fragStart);
119 }
120
121 const qsStart = path.indexOf('?');
122 if (qsStart > -1) {
123 queryString = path.substring(qsStart + 1);
124 path = path.substring(0, qsStart);
125 }
126
127 segments = path
128 .split('/')
129 .map((s) => s.trim())
130 .filter((s) => s.length > 0);
131
132 if (segments.length === 0) {
133 segments = [''];
134 }
135 }
136
137 return { segments, queryString, fragment };
138};

Callers 12

componentWillLoadMethod · 0.90
onPopStateMethod · 0.90
pushMethod · 0.90
runGuardsMethod · 0.90
getFragmentMethod · 0.90
readRedirectsFunction · 0.90
readRouteNodesFunction · 0.90
getRouteIDsFunction · 0.90
matching.spec.tsxFile · 0.90
path.spec.tsxFile · 0.90
writeSegmentsFunction · 0.85
readSegmentsFunction · 0.85

Calls

no outgoing calls

Tested by 1

getRouteIDsFunction · 0.72