Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert dropping support for backslashes in media URIs #2984

Merged
merged 1 commit into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mkdocs/tests/build_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

import sys
import unittest
from unittest import mock

Expand Down Expand Up @@ -180,7 +179,8 @@ def test_context_extra_css_js_from_nested_page_use_directory_urls(self):
self.assertEqual(context['extra_css'], ['../../style.css'])
self.assertEqual(context['extra_javascript'], ['../../script.js'])

@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
# TODO: This shouldn't pass on Linux
# @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_context_extra_css_path_warning(self):
nav_cfg = [
{'Home': 'index.md'},
Expand All @@ -200,8 +200,8 @@ def test_context_extra_css_path_warning(self):
self.assertEqual(context['extra_css'], ['assets/style.css'])
self.assertEqual(
'\n'.join(cm.output),
"WARNING:mkdocs.utils:Path 'assets\\style.css' uses OS-specific separator '\\', "
"change it to '/' so it is recognized on other systems.",
"WARNING:mkdocs.utils:Path 'assets\\style.css' uses OS-specific separator '\\'. "
"That will be unsupported in a future release. Please change it to '/'.",
)

def test_context_extra_css_js_no_page(self):
Expand Down
4 changes: 2 additions & 2 deletions mkdocs/tests/utils/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import posixpath
import stat
import sys
import unittest
from unittest import mock

Expand Down Expand Up @@ -245,7 +244,8 @@ def test_create_media_urls_use_directory_urls(self):
urls = utils.create_media_urls(expected_results.keys(), page)
self.assertEqual([v[i] for v in expected_results.values()], urls)

@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
# TODO: This shouldn't pass on Linux
# @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_create_media_urls_windows(self):
expected_results = {
'local\\windows\\file\\jquery.js': [
Expand Down
8 changes: 4 additions & 4 deletions mkdocs/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ def normalize_url(path: str, page: Optional[Page] = None, base: str = '') -> str
def _get_norm_url(path: str) -> Tuple[str, bool]:
if not path:
path = '.'
elif os.sep != '/' and os.sep in path:
elif '\\' in path:
log.warning(
f"Path '{path}' uses OS-specific separator '{os.sep}', "
f"change it to '/' so it is recognized on other systems."
f"Path '{path}' uses OS-specific separator '\\'. "
f"That will be unsupported in a future release. Please change it to '/'."
)
path = path.replace(os.sep, '/')
path = path.replace('\\', '/')
# Allow links to be fully qualified URLs
parsed = urlsplit(path)
if parsed.scheme or parsed.netloc or path.startswith(('/', '#')):
Expand Down