Commit fc0a36f7 authored by Waylan Limberg's avatar Waylan Limberg
Browse files

Simplify path_2_url.

We don't need most of the functionality in pathname2url so we might as
well only use the part we need. Fixes #1429.
parent dd7e2d91
......@@ -75,7 +75,9 @@ class UtilsTests(unittest.TestCase):
'//': '//',
'': './',
'local/file/jquery.js': './local/file/jquery.js',
'local\\windows\\file\\jquery.js': './local/windows/file/jquery.js',
'image.png': './image.png',
'style.css?v=20180308c': './style.css?v=20180308c'
site_navigation = nav.SiteNavigation(load_config(pages=pages))
for path, expected_result in expected_results.items():
......@@ -22,11 +22,9 @@ from mkdocs import exceptions
try: # pragma: no cover
from urllib.parse import urlparse, urlunparse, urljoin # noqa
from urllib.request import pathname2url # noqa
from collections import UserDict # noqa
except ImportError: # pragma: no cover
from urlparse import urlparse, urlunparse, urljoin # noqa
from urllib import pathname2url # noqa
from UserDict import UserDict # noqa
......@@ -360,12 +358,7 @@ def create_relative_media_url(nav, url):
def path_to_url(path):
"""Convert a system path to a URL."""
if os.path.sep == '/':
return path
if sys.version_info < (3, 0):
path = path.encode('utf8')
return pathname2url(path)
return '/'.join(path.split('\\'))
def get_theme_dir(name):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment