Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.parseJsonPointer = exports.joinJsonPointer = exports.buildJsonPointer = void 0;
|
---|
11 | function buildJsonPointer(fragments) {
|
---|
12 | return ('/' +
|
---|
13 | fragments
|
---|
14 | .map((f) => {
|
---|
15 | return f.replace(/~/g, '~0').replace(/\//g, '~1');
|
---|
16 | })
|
---|
17 | .join('/'));
|
---|
18 | }
|
---|
19 | exports.buildJsonPointer = buildJsonPointer;
|
---|
20 | function joinJsonPointer(root, ...others) {
|
---|
21 | if (root == '/') {
|
---|
22 | return buildJsonPointer(others);
|
---|
23 | }
|
---|
24 | return (root + buildJsonPointer(others));
|
---|
25 | }
|
---|
26 | exports.joinJsonPointer = joinJsonPointer;
|
---|
27 | function parseJsonPointer(pointer) {
|
---|
28 | if (pointer === '') {
|
---|
29 | return [];
|
---|
30 | }
|
---|
31 | if (pointer.charAt(0) !== '/') {
|
---|
32 | throw new Error('Relative pointer: ' + pointer);
|
---|
33 | }
|
---|
34 | return pointer
|
---|
35 | .substring(1)
|
---|
36 | .split(/\//)
|
---|
37 | .map((str) => str.replace(/~1/g, '/').replace(/~0/g, '~'));
|
---|
38 | }
|
---|
39 | exports.parseJsonPointer = parseJsonPointer;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.