From 385a18563cf9b3a16c8f23184b4d8f3d8c7dadba Mon Sep 17 00:00:00 2001 From: Irfan Ahmad Date: Mon, 10 Dec 2012 03:03:48 +0500 Subject: [PATCH] Fixes #630 --- pelican/tests/test_utils.py | 6 +++++- pelican/utils.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 78c90aeb..78e888eb 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -74,7 +74,11 @@ class TestUtils(LoggedTestCase): samples = ((os.path.join('test', 'test.html'), os.pardir), (os.path.join('test', 'test', 'test.html'), os.path.join(os.pardir, os.pardir)), - ('test.html', os.curdir)) + ('test.html', os.curdir), + (os.path.join('/test', 'test.html'), os.pardir), + (os.path.join('/test', 'test', 'test.html'), + os.path.join(os.pardir, os.pardir)), + ('/test.html', os.curdir),) for value, expected in samples: self.assertEquals(utils.get_relative_path(value), expected) diff --git a/pelican/utils.py b/pelican/utils.py index 417e5b15..3ae88402 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -501,8 +501,9 @@ def split_all(path): ['a', 'b', 'c'] """ components = [] + path = path.lstrip('/') while path: - head,tail = os.path.split(path) + head, tail = os.path.split(path) if tail: components.insert(0, tail) elif head == path: