Skip to content

Commit

Permalink
Support colon prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
bplatz committed Aug 19, 2024
1 parent 8cbbef7 commit 90a64c8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
17 changes: 0 additions & 17 deletions src/fluree/json_ld/impl/expand.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,3 @@
{:status 400
:error :json-ld/invalid}
e)))))))


(comment

(node {"@context" "https://schema.org",
"@id" "https://www.wikidata.org/wiki/Q836821",
"@type" "Movie",
"name" "HELLO The Hitchhiker's Guide to the Galaxy",
"disambiguatingDescription" "2005 British-American comic science fiction film directed by Garth Jennings",
"titleEIDR" "10.5240/B752-5B47-DBBE-E5D4-5A3F-N",
"isBasedOn" {"@id" "https://www.wikidata.org/wiki/Q3107329",
"@type" "Book",
"name" "The Hitchhiker's Guide to the Galaxy",
"isbn" "0-330-25864-8",
"author" {"@id" "https://www.wikidata.org/wiki/Q42"
"@type" "Person"
"name" "Douglas Adams"}}}))
5 changes: 3 additions & 2 deletions src/fluree/json_ld/impl/iri.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
[x]
(if (keyword? x)
[x (keyword (namespace x)) (name x)]
(re-matches #"([^:/]+):([^/:][^:]*)" x)))

(if (= \: (first x))
[x ":" (subs x 1)] ;; prefix is ':'
(re-matches #"([^:/]+):([^/:][^:]*)" x))))

(defn any-iri?
"Returns true if string has a colon, indicating it is either a compact
Expand Down
16 changes: 16 additions & 0 deletions test/fluree/json_ld/impl/expand_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,22 @@
(expand/node {"@id" "foo"
"bar" {"@value" false}})))))

(deftest empty-colon-test
(testing "Testing context key of ':' expands properly."
(is (= {"http://somedomain.org/age" [{:idx [":age"]
:type nil
:value 33}]
"http://example.com/vocab/name" [{:idx ["ex:name"]
:type nil
:value "Frank"}]
:idx []}
(expand/node {"@context"
{"ex" "http://example.com/vocab/"
":" "http://somedomain.org/"}
"ex:name" "Frank"
":age" 33})))))


(comment
(expanding-iri)
(expanding-reverse-iri)
Expand Down
4 changes: 2 additions & 2 deletions test/fluree/json_ld/impl/iri_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

(is (nil? (iri/parse-prefix "schema::name")))

(is (nil? (iri/parse-prefix ":schema:name")))
(is (= (iri/parse-prefix ":schema:name") [":" "schema:name"]))

(is (nil? (iri/parse-prefix ":schema")))
(is (= (iri/parse-prefix ":schema") [":" "schema"]))

(is (nil? (iri/parse-prefix "schema:")))

Expand Down

0 comments on commit 90a64c8

Please sign in to comment.