eyeling 1.6.10 → 1.6.11

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.
Files changed (2) hide show
  1. package/eyeling.js +12 -5
  2. package/package.json +1 -1
package/eyeling.js CHANGED
@@ -36,6 +36,12 @@ const STRING_NS = 'http://www.w3.org/2000/10/swap/string#';
36
36
  const SKOLEM_NS = 'https://eyereasoner.github.io/.well-known/genid/';
37
37
  const RDF_JSON_DT = RDF_NS + 'JSON';
38
38
 
39
+ function resolveIriRef(ref, base) {
40
+ if (!base) return ref;
41
+ if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(ref)) return ref; // already absolute
42
+ try { return new URL(ref, base).toString(); } catch { return ref; }
43
+ }
44
+
39
45
  function isRdfJsonDatatype(dt) {
40
46
  // dt comes from literalParts() and may be expanded or prefixed depending on parsing/printing.
41
47
  return dt === null || dt === RDF_JSON_DT || dt === 'rdf:JSON';
@@ -864,9 +870,9 @@ class Parser {
864
870
  }
865
871
 
866
872
  if (typ === 'IriRef') {
867
- return new Iri(val || '');
873
+ const base = this.prefixes.map[''] || '';
874
+ return new Iri(resolveIriRef(val || '', base));
868
875
  }
869
-
870
876
  if (typ === 'Ident') {
871
877
  const name = val || '';
872
878
  if (name === 'a') {
@@ -4296,9 +4302,10 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
4296
4302
  return s2 !== null ? [s2] : [];
4297
4303
  }
4298
4304
 
4299
- // If neither side is sufficiently instantiated (both vars, or wrong types),
4300
- // we don't enumerate URIs; the builtin just fails.
4301
- return [];
4305
+ const sOk = (g.s instanceof Var) || (g.s instanceof Blank) || (g.s instanceof Iri);
4306
+ const oOk = (g.o instanceof Var) || (g.o instanceof Blank) || (g.o instanceof Literal);
4307
+ if (!sOk || !oOk) return [];
4308
+ return [{ ...subst }];
4302
4309
  }
4303
4310
 
4304
4311
  // -----------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [