(allowPrimary: boolean, depth: number)
| 841 | |
| 842 | // parse `(a/b//outlet_name:c/d)` |
| 843 | private parseParens(allowPrimary: boolean, depth: number): {[outlet: string]: UrlSegmentGroup} { |
| 844 | // The outlet name is taken verbatim from the URL, so it can be `__proto__`. Indexing a plain |
| 845 | // object with that key assigns through the inherited `__proto__` setter instead of creating an |
| 846 | // outlet, which drops the outlet and mutates the map's prototype (and throws under Node's |
| 847 | // `--disable-proto=throw`). A null-prototype map makes `__proto__` an ordinary key. |
| 848 | const segments: {[key: string]: UrlSegmentGroup} = Object.create(null); |
| 849 | this.capture('('); |
| 850 | |
| 851 | while (!this.consumeOptional(')') && this.remaining.length > 0) { |
| 852 | const path = matchSegments(this.remaining); |
| 853 | |
| 854 | const next = this.remaining[path.length]; |
| 855 | |
| 856 | // if is is not one of these characters, then the segment was unescaped |
| 857 | // or the group was not closed |
| 858 | if (next !== '/' && next !== ')' && next !== ';') { |
| 859 | throw new RuntimeError( |
| 860 | RuntimeErrorCode.UNPARSABLE_URL, |
| 861 | (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot parse url '${this.url}'`, |
| 862 | ); |
| 863 | } |
| 864 | |
| 865 | let outletName: string | undefined; |
| 866 | if (path.indexOf(':') > -1) { |
| 867 | outletName = path.slice(0, path.indexOf(':')); |
| 868 | this.capture(outletName); |
| 869 | this.capture(':'); |
| 870 | } else if (allowPrimary) { |
| 871 | outletName = PRIMARY_OUTLET; |
| 872 | } |
| 873 | |
| 874 | const children = this.parseChildren(depth + 1); |
| 875 | const child = |
| 876 | Object.keys(children).length === 1 && children[PRIMARY_OUTLET] |
| 877 | ? children[PRIMARY_OUTLET] |
| 878 | : new UrlSegmentGroup([], children); |
| 879 | setUrlDerivedKey(segments, outletName ?? PRIMARY_OUTLET, child); |
| 880 | this.consumeOptional('//'); |
| 881 | } |
| 882 | |
| 883 | return segments; |
| 884 | } |
| 885 | |
| 886 | private peekStartsWith(str: string): boolean { |
| 887 | return this.remaining.startsWith(str); |
no test coverage detected