Sha256: 154e4944f69d152ad85d977247b672d0ab92d86c280625d384e5607bf84ffa82
Contents?: true
Size: 657 Bytes
Versions: 5
Compression:
Stored size: 657 Bytes
Contents
module TaliaUtil # Some helper methods to deal with URI and IRI strings module UriHelper # Removes all characters that are illegal in IRIs, so that the # URIs can be imported def irify(uri) N::URI.new(uri.to_s.gsub( /[<>"{}|\\^`\s]/, '+')).to_s end # Sanitize an URI to be passed into SPARQL queries def sanitize_sparql(uri_or_string) uri_or_string = uri_or_string.to_s.gsub( /[<>"{}|\\^`\s]/, '') # Remove forbidden chars that we know of URI.escape(uri_or_string) # Escape everything else uri_or_string.gsub('%23', '#') # Revert the hash character, we need that intact end end end
Version data entries
5 entries across 5 versions & 1 rubygems