uriTemplate.ts ×8

Frontier kind: Code frontier

unlabeled · c_387361464a0b

100 tests · 3428 LOC · 19 files · introduces 0 tests · 50 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges50 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
488 ranges3428 lines · 19 files · Browse complete extent
All tests (intent)
100 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 50 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/uriTemplate.ts 50 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- uriTemplate.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > export interface IUriTemplateVariable {
7 > readonly explodable: boolean;
8 > readonly name: string;
9 > readonly optional: boolean;
10 > readonly prefixLength?: number;
11 > readonly repeatable: boolean;
12 > }
13 >
14 > interface IUriTemplateComponent {
15 > readonly expression: string;
16 > readonly operator: string;
17 > readonly variables: readonly IUriTemplateVariable[];
18 > }
19 >
20 > /**
21 > * Represents an RFC 6570 URI Template.
22 > */
23 > export class UriTemplate {
24 > /**
25 > * The parsed template components (expressions).
26 > */
27 > public readonly components: ReadonlyArray<IUriTemplateComponent | string>;
28 >
29 > private constructor(
30 public readonly template: string,
31 components: ReadonlyArray<IUriTemplateComponent | string>
34 this.components = components;
35 }
37 > /**
38 > * Parses a URI template string into a UriTemplate instance.
39 > */
40 > public static parse(template: string): UriTemplate {
41 const components: Array<IUriTemplateComponent | string> = [];
42 const regex = /\{([^{}]+)\}/g;
88 return new UriTemplate(template, components);
89 }
91 > private static _operators = ['+', '#', '.', '/', ';', '?', '&'] as const;
92 > private static _isOperator(ch: string): boolean {
93 return (UriTemplate._operators as readonly string[]).includes(ch);
94 }
96 > /**
97 > * Resolves the template with the given variables.
98 > */
99 > public resolve(variables: Record<string, unknown>): string {
100 let result = '';
101 for (const comp of this.components) {
108 return result;
109 }
111 > private _expand(comp: IUriTemplateComponent, variables: Record<string, unknown>): string {
112 const op = comp.operator;
113 const varSpecs = comp.variables;
277 return joined;
278 }
280 > private static _encode(str: string, reserved: boolean): string {
281 return reserved ? encodeURI(str) : pctEncode(str);
282 }
284 > private static _formPair(k: string, v: unknown, named: boolean): string {
285 return named ? k + '=' + encodeURIComponent(String(v)) : encodeURIComponent(String(v));
286 }
287 > } uriTemplate.ts
288 >
289 function pctEncode(str: string): string {
290 let out = '';