MCPcopy
hub / github.com/angular/angular / parseQueryParam

Method parseQueryParam

packages/router/src/url_tree.ts:730–760  ·  view source on GitHub ↗
(params: Params)

Source from the content-addressed store, hash-verified

728
729 // Parse a single query parameter `name[=value]`
730 private parseQueryParam(params: Params): void {
731 const key = matchQueryParams(this.remaining);
732 if (!key) {
733 return;
734 }
735 this.capture(key);
736 let value: any = '';
737 if (this.consumeOptional('=')) {
738 const valueMatch = matchUrlQueryParamValue(this.remaining);
739 if (valueMatch) {
740 value = valueMatch;
741 this.capture(value);
742 }
743 }
744
745 const decodedKey = decodeQuery(key);
746 const decodedVal = decodeQuery(value);
747
748 if (params.hasOwnProperty(decodedKey)) {
749 // Append to existing values
750 let currentVal = params[decodedKey];
751 if (!Array.isArray(currentVal)) {
752 currentVal = [currentVal];
753 params[decodedKey] = currentVal;
754 }
755 currentVal.push(decodedVal);
756 } else {
757 // Create a new value
758 params[decodedKey] = decodedVal;
759 }
760 }
761
762 // parse `(a/b//outlet_name:c/d)`
763 private parseParens(allowPrimary: boolean, depth: number): {[outlet: string]: UrlSegmentGroup} {

Callers 1

parseQueryParamsMethod · 0.95

Calls 7

captureMethod · 0.95
consumeOptionalMethod · 0.95
matchQueryParamsFunction · 0.85
matchUrlQueryParamValueFunction · 0.85
decodeQueryFunction · 0.85
isArrayMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected