Re: relativize URI

> On Mar 11, 2015, at 1:30 PM, carmen <_@whats-your.name> wrote:
> 
> hi.. wondering about this function in various writer-classes:
> 
>   # If base_uri is defined, use it to try to make uri relative
>    # @param [#to_s] uri
>    # @return [String]
>    def relativize(uri)
>      uri = uri.to_s
>      base_uri ? uri.sub(base_uri.to_s, "") : uri
>    end
> 
> base /2015/03 shortens /2015/03/10 to /10
> 
> URI class has a #route_to/#route_from , which would probably be much slower than a naive string-substitution ...

Are you suggesting that RDF::URI implement `#relativize` instead of the writer classes, that we should use `#route_to/#route_from` from Addressable::URI? We can't really do the latter because it returns a _normalized_ URI, which could change the semantics (i.e., <foo/bar/> is different than <foo/./bar> for RDF purposes, even though they normalize to the same URI). Really, only string-substitution is appropriate here.

Driving this as an issue at http://github.com/ruby-rdf/rdf/issues will track this going forward if you'd like to see an enhancement.

Gregg

Received on Wednesday, 11 March 2015 20:52:31 UTC