@apidevtools/json-schema-ref-parser 11.2.3 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,11 +9,23 @@
9
9
  [![License](https://img.shields.io/npm/l/@apidevtools/json-schema-ref-parser.svg)](LICENSE)
10
10
  [![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/APIDevTools/json-schema-ref-parser)
11
11
 
12
+ Installation
13
+ --------------------------
14
+ Install using [npm](https://docs.npmjs.com/about-npm/):
15
+
16
+ ```bash
17
+ npm install @apidevtools/json-schema-ref-parser
18
+ yarn add @apidevtools/json-schema-ref-parser
19
+ bun add @apidevtools/json-schema-ref-parser
20
+ ```
21
+
12
22
  The Problem:
13
23
  --------------------------
14
- You've got a JSON Schema with `$ref` pointers to other files and/or URLs. Maybe you know all the referenced files ahead of time. Maybe you don't. Maybe some are local files, and others are remote URLs. Maybe they are a mix of JSON and YAML format. Maybe some of the files contain cross-references to each other.
24
+ You've got a JSON Schema with `$ref` pointers to other files and/or URLs. Maybe you know all the referenced files ahead
25
+ of time. Maybe you don't. Maybe some are local files, and others are remote URLs. Maybe they are a mix of JSON and YAML
26
+ format. Maybe some of the files contain cross-references to each other.
15
27
 
16
- ```javascript
28
+ ```json
17
29
  {
18
30
  "definitions": {
19
31
  "person": {
@@ -36,44 +48,36 @@ You've got a JSON Schema with `$ref` pointers to other files and/or URLs. Maybe
36
48
  }
37
49
  ```
38
50
 
39
-
40
51
  The Solution:
41
52
  --------------------------
42
- JSON Schema $Ref Parser is a full [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and [JSON Pointer](https://tools.ietf.org/html/rfc6901) implementation that crawls even the most complex [JSON Schemas](http://json-schema.org/latest/json-schema-core.html) and gives you simple, straightforward JavaScript objects.
53
+ JSON Schema $Ref Parser is a full [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
54
+ and [JSON Pointer](https://tools.ietf.org/html/rfc6901) implementation that crawls even the most
55
+ complex [JSON Schemas](http://json-schema.org/latest/json-schema-core.html) and gives you simple, straightforward
56
+ JavaScript objects.
43
57
 
44
58
  - Use **JSON** or **YAML** schemas — or even a mix of both!
45
- - Supports `$ref` pointers to external files and URLs, as well as [custom sources](https://apitools.dev/json-schema-ref-parser/docs/plugins/resolvers.html) such as databases
46
- - Can [bundle](https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#bundlepath-options-callback) multiple files into a single schema that only has _internal_ `$ref` pointers
47
- - Can [dereference](https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#dereferencepath-options-callback) your schema, producing a plain-old JavaScript object that's easy to work with
48
- - Supports [circular references](https://apitools.dev/json-schema-ref-parser/docs/#circular-refs), nested references, back-references, and cross-references between files
49
- - Maintains object reference equality — `$ref` pointers to the same value always resolve to the same object instance
50
- - Tested in Node v10, v12, & v14, and all major web browsers on Windows, Mac, and Linux
51
-
59
+ - Supports `$ref` pointers to external files and URLs, as well
60
+ as [custom sources](https://apitools.dev/json-schema-ref-parser/docs/plugins/resolvers.html) such as databases
61
+ - Can [bundle](https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#bundlepath-options-callback) multiple
62
+ files into a single schema that only has _internal_ `$ref` pointers
63
+ - Can [dereference](https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#dereferencepath-options-callback)
64
+ your schema, producing a plain-old JavaScript object that's easy to work with
65
+ - Supports [circular references](https://apitools.dev/json-schema-ref-parser/docs/#circular-refs), nested references,
66
+ back-references, and cross-references between files
67
+ - Maintains object reference equality — `$ref` pointers to the same value always resolve to the same object
68
+ instance
69
+ - Compatible with Node LTS and beyond, and all major web browsers on Windows, Mac, and Linux
52
70
 
53
71
  Example
54
72
  --------------------------
55
73
 
56
74
  ```javascript
57
- $RefParser.dereference(mySchema, (err, schema) => {
58
- if (err) {
59
- console.error(err);
60
- }
61
- else {
62
- // `schema` is just a normal JavaScript object that contains your entire JSON Schema,
63
- // including referenced files, combined into a single object
64
- console.log(schema.definitions.person.properties.firstName);
65
- }
66
- })
67
- ```
68
-
69
- Or use `async`/`await` syntax instead. The following example is the same as above:
75
+ import $RefParser from "@apidevtools/json-schema-ref-parser";
70
76
 
71
- ```javascript
72
77
  try {
73
78
  let schema = await $RefParser.dereference(mySchema);
74
79
  console.log(schema.definitions.person.properties.firstName);
75
- }
76
- catch(err) {
80
+ } catch (err) {
77
81
  console.error(err);
78
82
  }
79
83
  ```
@@ -81,99 +85,80 @@ catch(err) {
81
85
  For more detailed examples, please see the [API Documentation](https://apitools.dev/json-schema-ref-parser/docs/)
82
86
 
83
87
 
84
-
85
- Installation
88
+ Polyfills
86
89
  --------------------------
87
- Install using [npm](https://docs.npmjs.com/about-npm/):
88
90
 
89
- ```bash
90
- npm install @apidevtools/json-schema-ref-parser
91
- ```
92
91
 
92
+ If you are using Node.js < 18, you'll need a polyfill for `fetch`,
93
+ like [node-fetch](https://github.com/node-fetch/node-fetch):
93
94
 
94
-
95
- Usage
96
- --------------------------
97
- When using JSON Schema $Ref Parser in Node.js apps, you'll probably want to use **CommonJS** syntax:
98
-
99
- ```javascript
100
- const $RefParser = require("@apidevtools/json-schema-ref-parser");
101
- ```
102
-
103
- When using a transpiler such as [Babel](https://babeljs.io/) or [TypeScript](https://www.typescriptlang.org/), or a bundler such as [Webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/), you can use **ECMAScript modules** syntax instead:
104
-
105
- ```javascript
106
- import $RefParser from "@apidevtools/json-schema-ref-parser";
107
- ```
108
-
109
- If you are using Node.js < 18, you'll need a polyfill for `fetch`, like [node-fetch](https://github.com/node-fetch/node-fetch):
110
95
  ```javascript
111
96
  import fetch from "node-fetch";
112
97
 
113
98
  globalThis.fetch = fetch;
114
99
  ```
115
100
 
116
-
117
-
118
101
  Browser support
119
102
  --------------------------
120
- JSON Schema $Ref Parser supports recent versions of every major web browser. Older browsers may require [Babel](https://babeljs.io/) and/or [polyfills](https://babeljs.io/docs/en/next/babel-polyfill).
121
-
122
- To use JSON Schema $Ref Parser in a browser, you'll need to use a bundling tool such as [Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/), [Parcel](https://parceljs.org/), or [Browserify](http://browserify.org/). Some bundlers may require a bit of configuration, such as setting `browser: true` in [rollup-plugin-resolve](https://github.com/rollup/rollup-plugin-node-resolve).
103
+ JSON Schema $Ref Parser supports recent versions of every major web browser. Older browsers may
104
+ require [Babel](https://babeljs.io/) and/or [polyfills](https://babeljs.io/docs/en/next/babel-polyfill).
123
105
 
106
+ To use JSON Schema $Ref Parser in a browser, you'll need to use a bundling tool such
107
+ as [Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/), [Parcel](https://parceljs.org/),
108
+ or [Browserify](http://browserify.org/). Some bundlers may require a bit of configuration, such as
109
+ setting `browser: true` in [rollup-plugin-resolve](https://github.com/rollup/rollup-plugin-node-resolve).
124
110
 
125
111
  #### Webpack 5
126
- Webpack 5 has dropped the default export of node core modules in favour of polyfills, you'll need to set them up yourself ( after npm-installing them )
112
+
113
+ Webpack 5 has dropped the default export of node core modules in favour of polyfills, you'll need to set them up
114
+ yourself ( after npm-installing them )
127
115
  Edit your `webpack.config.js` :
116
+
128
117
  ```js
129
- config.resolve.fallback = {
130
- "path": require.resolve("path-browserify"),
131
- 'util': require.resolve('util/'),
132
- 'fs': require.resolve('browserify-fs'),
133
- "buffer": require.resolve("buffer/"),
134
- "http": require.resolve("stream-http"),
135
- "https": require.resolve("https-browserify"),
136
- "url": require.resolve("url"),
137
- }
118
+ config.resolve.fallback = {
119
+ "path": require.resolve("path-browserify"),
120
+ 'fs': require.resolve('browserify-fs')
121
+ }
138
122
 
139
- config.plugins.push(
140
- new webpack.ProvidePlugin({
141
- Buffer: [ 'buffer', 'Buffer']
142
- })
143
- )
123
+ config.plugins.push(
124
+ new webpack.ProvidePlugin({
125
+ Buffer: ['buffer', 'Buffer']
126
+ })
127
+ )
144
128
 
145
129
  ```
146
130
 
147
-
148
131
  API Documentation
149
132
  --------------------------
150
133
  Full API documentation is available [right here](https://apitools.dev/json-schema-ref-parser/docs/)
151
134
 
152
135
 
153
-
154
136
  Contributing
155
137
  --------------------------
156
- I welcome any contributions, enhancements, and bug-fixes. [Open an issue](https://github.com/APIDevTools/json-schema-ref-parser/issues) on GitHub and [submit a pull request](https://github.com/APIDevTools/json-schema-ref-parser/pulls).
138
+ I welcome any contributions, enhancements, and
139
+ bug-fixes. [Open an issue](https://github.com/APIDevTools/json-schema-ref-parser/issues) on GitHub
140
+ and [submit a pull request](https://github.com/APIDevTools/json-schema-ref-parser/pulls).
157
141
 
158
142
  #### Building/Testing
143
+
159
144
  To build/test the project locally on your computer:
160
145
 
161
146
  1. __Clone this repo__<br>
162
- `git clone https://github.com/APIDevTools/json-schema-ref-parser.git`
147
+ `git clone https://github.com/APIDevTools/json-schema-ref-parser.git`
163
148
 
164
149
  2. __Install dependencies__<br>
165
- `npm install`
150
+ `yarn install`
166
151
 
167
152
  3. __Run the tests__<br>
168
- `npm test`
169
-
170
-
153
+ `yarn test`
171
154
 
172
155
  License
173
156
  --------------------------
174
157
  JSON Schema $Ref Parser is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
175
158
 
176
- This package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/APIDevTools/json-schema-ref-parser) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
159
+ This package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a
160
+ tree**](https://plant.treeware.earth/APIDevTools/json-schema-ref-parser) to thank us for our work. By contributing to
161
+ the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
177
162
 
178
163
 
179
164
 
@@ -129,7 +129,6 @@ function crawl(obj, path, pathFromRoot, parents, processedObjects, dereferencedC
129
129
  * @returns
130
130
  */
131
131
  function dereference$Ref($ref, path, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options) {
132
- // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);
133
132
  const isExternalRef = ref_js_1.default.isExternal$Ref($ref);
134
133
  const shouldResolveOnCwd = isExternalRef && options?.dereference.externalReferenceResolution === "root";
135
134
  const $refPath = url.resolve(shouldResolveOnCwd ? url.cwd() : path, $ref.$ref);
@@ -2,7 +2,7 @@ import $Refs from "./refs.js";
2
2
  import { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError } from "./util/errors.js";
3
3
  import type { ParserOptions } from "./options.js";
4
4
  import type { Plugin, $RefsCallback, JSONSchema, SchemaCallback, HTTPResolverOptions, FileInfo, ResolverOptions, JSONSchemaObject } from "./types/index.js";
5
- export { JSONSchemaObject, ResolverOptions, ParserError, UnmatchedResolverError, ResolverError, HTTPResolverOptions, FileInfo, UnmatchedParserError, ParserOptions, MissingPointerError, InvalidPointerError, JSONParserError, Plugin, };
5
+ export { JSONSchemaObject, ResolverOptions, ParserError, UnmatchedResolverError, ResolverError, HTTPResolverOptions, FileInfo, UnmatchedParserError, ParserOptions, MissingPointerError, InvalidPointerError, JSONParserError, Plugin, JSONSchema, $RefsCallback, SchemaCallback, };
6
6
  export type RefParserSchema = string | JSONSchema;
7
7
  /**
8
8
  * This class parses a JSON schema, builds a map of its JSON references and their resolved values,
@@ -17,6 +17,10 @@ exports.default = {
17
17
  * every parser will be tried.
18
18
  */
19
19
  canParse: ".json",
20
+ /**
21
+ * Allow JSON files with byte order marks (BOM)
22
+ */
23
+ allowBOM: true,
20
24
  /**
21
25
  * Parses the given file as JSON
22
26
  */
@@ -34,6 +38,18 @@ exports.default = {
34
38
  return JSON.parse(data);
35
39
  }
36
40
  catch (e) {
41
+ if (this.allowBOM) {
42
+ try {
43
+ // find the first curly brace
44
+ const firstCurlyBrace = data.indexOf("{");
45
+ // remove any characters before the first curly brace
46
+ data = data.slice(firstCurlyBrace);
47
+ return JSON.parse(data);
48
+ }
49
+ catch (e) {
50
+ throw new errors_js_1.ParserError(e.message, file.url);
51
+ }
52
+ }
37
53
  throw new errors_js_1.ParserError(e.message, file.url);
38
54
  }
39
55
  }
@@ -36,7 +36,7 @@ declare class Pointer {
36
36
  * Resolving a single pointer may require resolving multiple $Refs.
37
37
  */
38
38
  indirections: number;
39
- constructor($ref: any, path: any, friendlyPath?: string);
39
+ constructor($ref: $Ref, path: string, friendlyPath?: string);
40
40
  /**
41
41
  * Resolves the value of a nested property within the given object.
42
42
  *
@@ -33,6 +33,14 @@ const slashes = /\//g;
33
33
  const tildes = /~/g;
34
34
  const escapedSlash = /~1/g;
35
35
  const escapedTilde = /~0/g;
36
+ const safeDecodeURIComponent = (encodedURIComponent) => {
37
+ try {
38
+ return decodeURIComponent(encodedURIComponent);
39
+ }
40
+ catch {
41
+ return encodedURIComponent;
42
+ }
43
+ };
36
44
  /**
37
45
  * This class represents a single JSON pointer and its resolved value.
38
46
  *
@@ -77,6 +85,20 @@ class Pointer {
77
85
  }
78
86
  const token = tokens[i];
79
87
  if (this.value[token] === undefined || (this.value[token] === null && i === tokens.length - 1)) {
88
+ // one final case is if the entry itself includes slashes, and was parsed out as a token - we can join the remaining tokens and try again
89
+ let didFindSubstringSlashMatch = false;
90
+ for (let j = tokens.length - 1; j > i; j--) {
91
+ const joinedToken = tokens.slice(i, j + 1).join("/");
92
+ if (this.value[joinedToken] !== undefined) {
93
+ this.value = this.value[joinedToken];
94
+ i = j;
95
+ didFindSubstringSlashMatch = true;
96
+ break;
97
+ }
98
+ }
99
+ if (didFindSubstringSlashMatch) {
100
+ continue;
101
+ }
80
102
  this.value = null;
81
103
  throw new errors_js_1.MissingPointerError(token, decodeURI(this.originalPath));
82
104
  }
@@ -153,7 +175,7 @@ class Pointer {
153
175
  pointer = pointer.split("/");
154
176
  // Decode each part, according to RFC 6901
155
177
  for (let i = 0; i < pointer.length; i++) {
156
- pointer[i] = decodeURIComponent(pointer[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
178
+ pointer[i] = safeDecodeURIComponent(pointer[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
157
179
  }
158
180
  if (pointer[0] !== "") {
159
181
  throw new errors_js_1.InvalidPointerError(pointer, originalPath === undefined ? path : originalPath);
@@ -64,6 +64,12 @@ export interface Plugin {
64
64
  * You can set `allowEmpty: false` on any parser, which will cause an error to be thrown if a file empty.
65
65
  */
66
66
  allowEmpty?: boolean;
67
+ /**
68
+ * Specifies whether a Byte Order Mark (BOM) is allowed or not. Only applies to JSON parsing
69
+ *
70
+ * @type {boolean} @default true
71
+ */
72
+ allowBOM?: boolean;
67
73
  /**
68
74
  * The encoding that the text is expected to be in.
69
75
  */
@@ -215,8 +215,11 @@ function fromFileSystemPath(path) {
215
215
  const posixUpper = projectDirPosixPath.toUpperCase();
216
216
  const hasProjectDir = upperPath.includes(posixUpper);
217
217
  const hasProjectUri = upperPath.includes(posixUpper);
218
- const isAbsolutePath = path_1.win32?.isAbsolute(path);
219
- if (!(hasProjectDir || hasProjectUri || isAbsolutePath)) {
218
+ const isAbsolutePath = path_1.win32?.isAbsolute(path) ||
219
+ path.startsWith("http://") ||
220
+ path.startsWith("https://") ||
221
+ path.startsWith("file://");
222
+ if (!(hasProjectDir || hasProjectUri || isAbsolutePath) && !projectDir.startsWith("http")) {
220
223
  path = (0, path_2.join)(projectDir, path);
221
224
  }
222
225
  path = (0, convert_path_to_posix_1.default)(path);
@@ -159,16 +159,14 @@ function crawl(
159
159
  */
160
160
  function dereference$Ref(
161
161
  $ref: any,
162
- path: any,
163
- pathFromRoot: any,
164
- parents: any,
162
+ path: string,
163
+ pathFromRoot: string,
164
+ parents: Set<any>,
165
165
  processedObjects: any,
166
166
  dereferencedCache: any,
167
- $refs: any,
168
- options: any,
167
+ $refs: $Refs,
168
+ options: $RefParserOptions,
169
169
  ) {
170
- // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);
171
-
172
170
  const isExternalRef = $Ref.isExternal$Ref($ref);
173
171
  const shouldResolveOnCwd = isExternalRef && options?.dereference.externalReferenceResolution === "root";
174
172
  const $refPath = url.resolve(shouldResolveOnCwd ? url.cwd() : path, $ref.$ref);
package/lib/index.ts CHANGED
@@ -44,6 +44,9 @@ export {
44
44
  InvalidPointerError,
45
45
  JSONParserError,
46
46
  Plugin,
47
+ JSONSchema,
48
+ $RefsCallback,
49
+ SchemaCallback,
47
50
  };
48
51
 
49
52
  export type RefParserSchema = string | JSONSchema;
@@ -21,6 +21,11 @@ export default {
21
21
  */
22
22
  canParse: ".json",
23
23
 
24
+ /**
25
+ * Allow JSON files with byte order marks (BOM)
26
+ */
27
+ allowBOM: true,
28
+
24
29
  /**
25
30
  * Parses the given file as JSON
26
31
  */
@@ -37,6 +42,17 @@ export default {
37
42
  try {
38
43
  return JSON.parse(data);
39
44
  } catch (e: any) {
45
+ if (this.allowBOM) {
46
+ try {
47
+ // find the first curly brace
48
+ const firstCurlyBrace = data.indexOf("{");
49
+ // remove any characters before the first curly brace
50
+ data = data.slice(firstCurlyBrace);
51
+ return JSON.parse(data);
52
+ } catch (e: any) {
53
+ throw new ParserError(e.message, file.url);
54
+ }
55
+ }
40
56
  throw new ParserError(e.message, file.url);
41
57
  }
42
58
  }
package/lib/pointer.ts CHANGED
@@ -3,11 +3,20 @@ import type $RefParserOptions from "./options.js";
3
3
  import $Ref from "./ref.js";
4
4
  import * as url from "./util/url.js";
5
5
  import { JSONParserError, InvalidPointerError, MissingPointerError, isHandledError } from "./util/errors.js";
6
+
6
7
  const slashes = /\//g;
7
8
  const tildes = /~/g;
8
9
  const escapedSlash = /~1/g;
9
10
  const escapedTilde = /~0/g;
10
11
 
12
+ const safeDecodeURIComponent = (encodedURIComponent: string): string => {
13
+ try {
14
+ return decodeURIComponent(encodedURIComponent);
15
+ } catch {
16
+ return encodedURIComponent;
17
+ }
18
+ };
19
+
11
20
  /**
12
21
  * This class represents a single JSON pointer and its resolved value.
13
22
  *
@@ -49,7 +58,7 @@ class Pointer {
49
58
  */
50
59
  indirections: number;
51
60
 
52
- constructor($ref: any, path: any, friendlyPath?: string) {
61
+ constructor($ref: $Ref, path: string, friendlyPath?: string) {
53
62
  this.$ref = $ref;
54
63
 
55
64
  this.path = path;
@@ -94,6 +103,21 @@ class Pointer {
94
103
 
95
104
  const token = tokens[i];
96
105
  if (this.value[token] === undefined || (this.value[token] === null && i === tokens.length - 1)) {
106
+ // one final case is if the entry itself includes slashes, and was parsed out as a token - we can join the remaining tokens and try again
107
+ let didFindSubstringSlashMatch = false;
108
+ for (let j = tokens.length - 1; j > i; j--) {
109
+ const joinedToken = tokens.slice(i, j + 1).join("/");
110
+ if (this.value[joinedToken] !== undefined) {
111
+ this.value = this.value[joinedToken];
112
+ i = j;
113
+ didFindSubstringSlashMatch = true;
114
+ break;
115
+ }
116
+ }
117
+ if (didFindSubstringSlashMatch) {
118
+ continue;
119
+ }
120
+
97
121
  this.value = null;
98
122
  throw new MissingPointerError(token, decodeURI(this.originalPath));
99
123
  } else {
@@ -181,7 +205,7 @@ class Pointer {
181
205
 
182
206
  // Decode each part, according to RFC 6901
183
207
  for (let i = 0; i < pointer.length; i++) {
184
- pointer[i] = decodeURIComponent(pointer[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
208
+ pointer[i] = safeDecodeURIComponent(pointer[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
185
209
  }
186
210
 
187
211
  if (pointer[0] !== "") {
@@ -88,6 +88,13 @@ export interface Plugin {
88
88
  */
89
89
  allowEmpty?: boolean;
90
90
 
91
+ /**
92
+ * Specifies whether a Byte Order Mark (BOM) is allowed or not. Only applies to JSON parsing
93
+ *
94
+ * @type {boolean} @default true
95
+ */
96
+ allowBOM?: boolean;
97
+
91
98
  /**
92
99
  * The encoding that the text is expected to be in.
93
100
  */
package/lib/util/url.ts CHANGED
@@ -191,9 +191,13 @@ export function fromFileSystemPath(path: string) {
191
191
  const posixUpper = projectDirPosixPath.toUpperCase();
192
192
  const hasProjectDir = upperPath.includes(posixUpper);
193
193
  const hasProjectUri = upperPath.includes(posixUpper);
194
- const isAbsolutePath = win32?.isAbsolute(path);
194
+ const isAbsolutePath =
195
+ win32?.isAbsolute(path) ||
196
+ path.startsWith("http://") ||
197
+ path.startsWith("https://") ||
198
+ path.startsWith("file://");
195
199
 
196
- if (!(hasProjectDir || hasProjectUri || isAbsolutePath)) {
200
+ if (!(hasProjectDir || hasProjectUri || isAbsolutePath) && !projectDir.startsWith("http")) {
197
201
  path = join(projectDir, path);
198
202
  }
199
203
  path = convertPathToPosix(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apidevtools/json-schema-ref-parser",
3
- "version": "11.2.3",
3
+ "version": "11.3.0",
4
4
  "description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5
5
  "keywords": [
6
6
  "json",
package/lib/tsconfig.json DELETED
@@ -1,103 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- // "jsx": "preserve", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
- /* Modules */
28
- "module": "commonjs", /* Specify what module code is generated. */
29
- // "rootDir": "./", /* Specify the root folder within your source files. */
30
- // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- // "resolveJsonModule": true, /* Enable importing .json files. */
39
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
-
41
- /* JavaScript Support */
42
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
-
46
- /* Emit */
47
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
- // "outDir": "./", /* Specify an output folder for all emitted files. */
53
- // "removeComments": true, /* Disable emitting comments. */
54
- // "noEmit": true, /* Disable emitting files from a compilation. */
55
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
- // "newLine": "crlf", /* Set the newline character for emitting files. */
64
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
-
71
- /* Interop Constraints */
72
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
-
78
- /* Type Checking */
79
- "strict": true, /* Enable all strict type-checking options. */
80
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
-
99
- /* Completeness */
100
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
- }
103
- }