summaryrefslogtreecommitdiff
path: root/fs/path.py
diff options
context:
space:
mode:
Diffstat (limited to 'fs/path.py')
-rw-r--r--fs/path.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/path.py b/fs/path.py
index ec97d1c..8967900 100644
--- a/fs/path.py
+++ b/fs/path.py
@@ -411,12 +411,13 @@ def relativefrom(base, path):
base = list(iteratepath(base))
path = list(iteratepath(path))
- while base and path and base[0] == path[0]:
- base.pop(0)
- path.pop(0)
+ common = 0
+ for a, b in zip(base, path):
+ if a != b:
+ break
+ common += 1
- # If you multiply a list by a negative number, you get an empty list!
- return u'/'.join([u'..'] * len(base) + path)
+ return u'/'.join([u'..'] * (len(base) - common) + path[common:])
class PathMap(object):