Skip to content

Commit

Permalink
fix: jsonld prefix patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Jan 11, 2024
1 parent 7db8943 commit 8e5db02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-rings-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/rdf-converter": patch
---

Aliased keywords were interpreted as prefixes
16 changes: 13 additions & 3 deletions patches/@rdfjs+parser-jsonld+2.1.0.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
diff --git a/node_modules/@rdfjs/parser-jsonld/lib/ParserStream.js b/node_modules/@rdfjs/parser-jsonld/lib/ParserStream.js
index fcfe40a..6ddc25c 100644
index fcfe40a..7ef06c7 100644
--- a/node_modules/@rdfjs/parser-jsonld/lib/ParserStream.js
+++ b/node_modules/@rdfjs/parser-jsonld/lib/ParserStream.js
@@ -63,11 +63,19 @@ class ParserStream {
@@ -4,6 +4,7 @@ import { JsonLdParser } from 'jsonld-streaming-parser'
import { Transform } from 'readable-stream'

const relativeIriProtocol = 'null:'
+const REGEX_KEYWORD = /^@[a-zA-Z]+$/;

function termCleanup (factory) {
return term => {
@@ -63,11 +64,21 @@ class ParserStream {
}
})

Expand All @@ -18,7 +26,9 @@ index fcfe40a..6ddc25c 100644
+
+ if(typeof context === 'object') {
+ Object.entries(context).forEach(([prefix, iri]) => {
+ transform.emit('prefix', prefix, factory.namedNode(iri))
+ if(iri && !REGEX_KEYWORD.test(iri)) {
+ transform.emit('prefix', prefix, factory.namedNode(iri))
+ }
+ })
+ }
+ }
Expand Down

0 comments on commit 8e5db02

Please sign in to comment.