File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ def empty?
198198 def base = ( value )
199199 if value
200200 raise JsonLdError ::InvalidBaseIRI , "@base must be a string: #{ value . inspect } " unless value . is_a? ( String ) || value . is_a? ( RDF ::URI )
201- @base = RDF ::URI ( value ) . dup
201+ @base = @base ? @base . join ( value ) : RDF ::URI ( value ) . dup
202202 @base . canonicalize!
203203 @base . fragment = nil
204204 @base . query = nil
Original file line number Diff line number Diff line change @@ -603,6 +603,28 @@ def containers
603603
604604 end
605605
606+ describe "#base=" do
607+ subject {
608+ context . parse ( {
609+ '@base' => 'http://base/' ,
610+ '@vocab' => 'http://vocab/' ,
611+ 'ex' => 'http://example.org/' ,
612+ '' => 'http://empty/' ,
613+ '_' => 'http://underscore/'
614+ } )
615+ }
616+
617+ it "sets new base uri given an absolute uri" do
618+ subject . base = "http://example.org/"
619+ expect ( subject . base ) . to eql RDF ::URI ( "http://example.org/" )
620+ end
621+
622+ it "sets relative URI" do
623+ subject . base = "foo/bar"
624+ expect ( subject . base ) . to eql RDF ::URI ( "http://base/foo/bar" )
625+ end
626+ end
627+
606628 describe "#expand_iri" do
607629 subject {
608630 context . parse ( {
You can’t perform that action at this time.
0 commit comments