mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
relative_uri patch. Fixes #916.
This commit is contained in:
parent
249ee22c4d
commit
2f1f4c6be2
@ -40,12 +40,20 @@ def relative_uri(base, to):
|
|||||||
return to
|
return to
|
||||||
b2 = base.split(SEP)
|
b2 = base.split(SEP)
|
||||||
t2 = to.split(SEP)
|
t2 = to.split(SEP)
|
||||||
# remove common segments
|
# remove common segments (except the last segment)
|
||||||
for x, y in zip(b2, t2):
|
for x, y in zip(b2[:-1], t2[:-1]):
|
||||||
if x != y:
|
if x != y:
|
||||||
break
|
break
|
||||||
b2.pop(0)
|
b2.pop(0)
|
||||||
t2.pop(0)
|
t2.pop(0)
|
||||||
|
if b2 == t2:
|
||||||
|
# Special case: relative_uri('f/index.html','f/index.html')
|
||||||
|
# returns '', not 'index.html'
|
||||||
|
return ''
|
||||||
|
if len(b2) == 1 and t2 == ['']:
|
||||||
|
# Special case: relative_uri('f/index.html','f/') should
|
||||||
|
# return './', not ''
|
||||||
|
return '.' + SEP
|
||||||
return ('..' + SEP) * (len(b2)-1) + SEP.join(t2)
|
return ('..' + SEP) * (len(b2)-1) + SEP.join(t2)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user