Revert dropping support for backslashes in media URIs (#2984)

Only show a warning for now.
This commit is contained in:
Oleh Prypin
2022-09-25 14:53:40 +02:00
committed by GitHub
parent dce025e544
commit 9c48c3317f
3 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python
import sys
import unittest
from unittest import mock
@@ -180,7 +179,8 @@ class BuildTests(PathAssertionMixin, unittest.TestCase):
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'},
@@ -200,8 +200,8 @@ class BuildTests(PathAssertionMixin, unittest.TestCase):
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):

View File

@@ -5,7 +5,6 @@ import logging
import os
import posixpath
import stat
import sys
import unittest
from unittest import mock
@@ -245,7 +244,8 @@ class UtilsTests(unittest.TestCase):
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': [

View File

@@ -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(('/', '#')):