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

Method parseQueryParam

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

Source from the content-addressed store, hash-verified

808
809 // Parse a single query parameter `name[=value]`
810 private parseQueryParam(params: Params): void {
811 const key = matchQueryParams(this.remaining);
812 if (!key) {
813 return;
814 }
815 this.capture(key);
816 let value = '';
817 if (this.consumeOptional('=')) {
818 const valueMatch = matchUrlQueryParamValue(this.remaining);
819 if (valueMatch) {
820 value = valueMatch;
821 this.capture(value);
822 }
823 }
824
825 const decodedKey = decodeQuery(key);
826 const decodedVal = decodeQuery(value);
827
828 if (Object.hasOwn(params, decodedKey)) {
829 // Append to existing values
830 let currentVal = params[decodedKey];
831 if (!Array.isArray(currentVal)) {
832 currentVal = [currentVal];
833 params[decodedKey] = currentVal;
834 }
835 currentVal.push(decodedVal);
836 } else {
837 // Create a new value
838 params[decodedKey] = decodedVal;
839 }
840 }
841
842 // parse `(a/b//outlet_name:c/d)`
843 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