MCPcopy Create free account
hub / github.com/angular/angular / serialize

Method serialize

packages/router/src/url_tree.ts:455–469  ·  view source on GitHub ↗

Converts a `UrlTree` into a url

(tree: UrlTree)

Source from the content-addressed store, hash-verified

453
454 /** Converts a `UrlTree` into a url */
455 serialize(tree: UrlTree): string {
456 const segment = `/${serializeSegment(tree.root, true)}`;
457 if (segment.startsWith('//')) {
458 throw new RuntimeError(
459 RuntimeErrorCode.PROTOCOL_RELATIVE_URL_NOT_ALLOWED,
460 (typeof ngDevMode === 'undefined' || ngDevMode) &&
461 'Cannot serialize a UrlTree that would produce a protocol-relative URL.',
462 );
463 }
464 const query = serializeQueryParams(tree.queryParams);
465 const fragment =
466 typeof tree.fragment === `string` ? `#${encodeUriFragment(tree.fragment)}` : '';
467
468 return `${segment}${query}${fragment}`;
469 }
470}
471
472const DEFAULT_SERIALIZER = new DefaultUrlSerializer();

Callers 1

expectTreeToBeFunction · 0.95

Calls 3

serializeSegmentFunction · 0.85
serializeQueryParamsFunction · 0.85
encodeUriFragmentFunction · 0.85

Tested by 1

expectTreeToBeFunction · 0.76