Skip to content

Commit

Permalink
fix for issue RDFLib#65, namespaces with #
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristina Sahlmann committed Sep 4, 2019
1 parent 070d45c commit a0cb1b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions rdflib_jsonld/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def base(self):

@base.setter
def base(self, base):
if base:
hash_index = base.find('#')
if hash_index > -1:
base = base[0:hash_index]
#if base:
#hash_index = base.find('#')
#if hash_index > -1:
#base = base[0:hash_index]
self._base = self.resolve_iri(base) if (
hasattr(self, '_base') and base is not None) else base
self._basedomain = '%s://%s' % urlsplit(base)[0:2] if base else None
Expand Down
17 changes: 9 additions & 8 deletions rdflib_jsonld/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ def norm_url(base, url):
'http://example.net/one'
"""
parts = urlsplit(urljoin(base, url))
path = normpath(parts[2])
if sep != '/':
path = '/'.join(path.split(sep))
if parts[2].endswith('/') and not path.endswith('/'):
path += '/'
result = urlunsplit(parts[0:2] + (path,) + parts[3:])
if url.endswith('#') and not result.endswith('#'):
result += '#'
#path = normpath(parts[2])
#if sep != '/':
# path = '/'.join(path.split(sep))
#if parts[2].endswith('/') and not path.endswith('/'):
# path += '/'
#result = urlunsplit(parts[0:2] + (path,) + parts[3:])
#if url.endswith('#') and not result.endswith('#'):
# result += '#'
result = url
return result

def context_from_urlinputsource(source):
Expand Down

0 comments on commit a0cb1b5

Please sign in to comment.