massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / vscode-json-languageserver / out / requests.js
1 "use strict";\r
2 /*---------------------------------------------------------------------------------------------\r
3  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
5  *--------------------------------------------------------------------------------------------*/\r
6 Object.defineProperty(exports, "__esModule", { value: true });\r
7 exports.joinPath = exports.normalizePath = exports.resolvePath = exports.isAbsolutePath = exports.extname = exports.basename = exports.dirname = exports.getScheme = void 0;\r
8 const vscode_uri_1 = require("vscode-uri");\r
9 function getScheme(uri) {\r
10     return uri.substr(0, uri.indexOf(':'));\r
11 }\r
12 exports.getScheme = getScheme;\r
13 function dirname(uri) {\r
14     const lastIndexOfSlash = uri.lastIndexOf('/');\r
15     return lastIndexOfSlash !== -1 ? uri.substr(0, lastIndexOfSlash) : '';\r
16 }\r
17 exports.dirname = dirname;\r
18 function basename(uri) {\r
19     const lastIndexOfSlash = uri.lastIndexOf('/');\r
20     return uri.substr(lastIndexOfSlash + 1);\r
21 }\r
22 exports.basename = basename;\r
23 const Slash = '/'.charCodeAt(0);\r
24 const Dot = '.'.charCodeAt(0);\r
25 function extname(uri) {\r
26     for (let i = uri.length - 1; i >= 0; i--) {\r
27         const ch = uri.charCodeAt(i);\r
28         if (ch === Dot) {\r
29             if (i > 0 && uri.charCodeAt(i - 1) !== Slash) {\r
30                 return uri.substr(i);\r
31             }\r
32             else {\r
33                 break;\r
34             }\r
35         }\r
36         else if (ch === Slash) {\r
37             break;\r
38         }\r
39     }\r
40     return '';\r
41 }\r
42 exports.extname = extname;\r
43 function isAbsolutePath(path) {\r
44     return path.charCodeAt(0) === Slash;\r
45 }\r
46 exports.isAbsolutePath = isAbsolutePath;\r
47 function resolvePath(uriString, path) {\r
48     if (isAbsolutePath(path)) {\r
49         const uri = vscode_uri_1.URI.parse(uriString);\r
50         const parts = path.split('/');\r
51         return uri.with({ path: normalizePath(parts) }).toString();\r
52     }\r
53     return joinPath(uriString, path);\r
54 }\r
55 exports.resolvePath = resolvePath;\r
56 function normalizePath(parts) {\r
57     const newParts = [];\r
58     for (const part of parts) {\r
59         if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {\r
60             // ignore\r
61         }\r
62         else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {\r
63             newParts.pop();\r
64         }\r
65         else {\r
66             newParts.push(part);\r
67         }\r
68     }\r
69     if (parts.length > 1 && parts[parts.length - 1].length === 0) {\r
70         newParts.push('');\r
71     }\r
72     let res = newParts.join('/');\r
73     if (parts[0].length === 0) {\r
74         res = '/' + res;\r
75     }\r
76     return res;\r
77 }\r
78 exports.normalizePath = normalizePath;\r
79 function joinPath(uriString, ...paths) {\r
80     const uri = vscode_uri_1.URI.parse(uriString);\r
81     const parts = uri.path.split('/');\r
82     for (let path of paths) {\r
83         parts.push(...path.split('/'));\r
84     }\r
85     return uri.with({ path: normalizePath(parts) }).toString();\r
86 }\r
87 exports.joinPath = joinPath;\r
88 //# sourceMappingURL=requests.js.map