n3 1.25.1 → 1.25.2

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/lib/BaseIRI.js CHANGED
@@ -8,7 +8,8 @@ var _Util = require("./Util");
8
8
  // Do not handle base IRIs without scheme, and currently unsupported cases:
9
9
  // - file: IRIs (which could also use backslashes)
10
10
  // - IRIs containing /. or /.. or //
11
- const INVALID_OR_UNSUPPORTED = /^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i;
11
+ const BASE_UNSUPPORTED = /^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i;
12
+ const SUFFIX_SUPPORTED = /^(?:(?:[^/?#]{3,}|\.?[^/?#.]\.?)(?:\/[^/?#]{3,}|\.?[^/?#.]\.?)*\/?)?(?:[?#]|$)/;
12
13
  const CURRENT = './';
13
14
  const PARENT = '../';
14
15
  const QUERY = '?';
@@ -21,7 +22,7 @@ class BaseIRI {
21
22
  this._pathReplacements = new Array(base.length + 1);
22
23
  }
23
24
  static supports(base) {
24
- return !INVALID_OR_UNSUPPORTED.test(base);
25
+ return !BASE_UNSUPPORTED.test(base);
25
26
  }
26
27
  _getBaseMatcher() {
27
28
  if (this._baseMatcher) return this._baseMatcher;
@@ -78,11 +79,7 @@ class BaseIRI {
78
79
  if (parentPath) {
79
80
  const suffix = iri.substring(length);
80
81
  // Don't abbreviate unsupported path
81
- if (parentPath !== QUERY && /(?:^|\/)(?:\/|..?(?:[/#?]|$))/.test(suffix) &&
82
- // fast test
83
- /^(?:[^#?]*?\/)?(?:\/|\.\.?(?:[/#?]|$))/.test(suffix))
84
- // rigorous test
85
- return iri;
82
+ if (parentPath !== QUERY && !SUFFIX_SUPPORTED.test(suffix)) return iri;
86
83
  // Omit ./ with fragment or query string
87
84
  if (parentPath === CURRENT && /^[^?#]/.test(suffix)) return suffix;
88
85
  // Append suffix to relative parent path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "1.25.1",
3
+ "version": "1.25.2",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
package/src/BaseIRI.js CHANGED
@@ -3,7 +3,8 @@ import { escapeRegex } from './Util';
3
3
  // Do not handle base IRIs without scheme, and currently unsupported cases:
4
4
  // - file: IRIs (which could also use backslashes)
5
5
  // - IRIs containing /. or /.. or //
6
- const INVALID_OR_UNSUPPORTED = /^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i;
6
+ const BASE_UNSUPPORTED = /^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i;
7
+ const SUFFIX_SUPPORTED = /^(?:(?:[^/?#]{3,}|\.?[^/?#.]\.?)(?:\/[^/?#]{3,}|\.?[^/?#.]\.?)*\/?)?(?:[?#]|$)/;
7
8
  const CURRENT = './';
8
9
  const PARENT = '../';
9
10
  const QUERY = '?';
@@ -18,7 +19,7 @@ export default class BaseIRI {
18
19
  }
19
20
 
20
21
  static supports(base) {
21
- return !INVALID_OR_UNSUPPORTED.test(base);
22
+ return !BASE_UNSUPPORTED.test(base);
22
23
  }
23
24
 
24
25
  _getBaseMatcher() {
@@ -85,9 +86,7 @@ export default class BaseIRI {
85
86
  if (parentPath) {
86
87
  const suffix = iri.substring(length);
87
88
  // Don't abbreviate unsupported path
88
- if (parentPath !== QUERY &&
89
- /(?:^|\/)(?:\/|..?(?:[/#?]|$))/.test(suffix) && // fast test
90
- /^(?:[^#?]*?\/)?(?:\/|\.\.?(?:[/#?]|$))/.test(suffix)) // rigorous test
89
+ if (parentPath !== QUERY && !SUFFIX_SUPPORTED.test(suffix))
91
90
  return iri;
92
91
  // Omit ./ with fragment or query string
93
92
  if (parentPath === CURRENT && /^[^?#]/.test(suffix))