MCPcopy Index your code
hub / github.com/angular/angular-cli / buildPathWithParams

Function buildPathWithParams

packages/angular/ssr/src/utils/url.ts:184–204  ·  view source on GitHub ↗
(toPath: string, fromPath: string)

Source from the content-addressed store, hash-verified

182 * ```
183 */
184export function buildPathWithParams(toPath: string, fromPath: string): string {
185 if (toPath[0] !== '/') {
186 throw new Error(`Invalid toPath: The string must start with a '/'. Received: '${toPath}'`);
187 }
188
189 if (fromPath[0] !== '/') {
190 throw new Error(`Invalid fromPath: The string must start with a '/'. Received: '${fromPath}'`);
191 }
192
193 if (!toPath.includes('/*')) {
194 return toPath;
195 }
196
197 const fromPathParts = fromPath.split('/');
198 const toPathParts = toPath.split('/');
199 const resolvedParts = toPathParts.map((part, index) =>
200 toPathParts[index] === '*' ? fromPathParts[index] : part,
201 );
202
203 return joinUrlParts(...resolvedParts);
204}
205
206const MATRIX_PARAMS_REGEX = /;[^/]+/g;
207

Callers 2

url_spec.tsFile · 0.90
handleMethod · 0.90

Calls 1

joinUrlPartsFunction · 0.85

Tested by

no test coverage detected