diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index efc4ecc..adab0d0 100644
a
|
b
|
def filepath_to_uri(path):
|
234 | 234 | return path |
235 | 235 | # I know about `os.sep` and `os.altsep` but I want to leave |
236 | 236 | # some flexibility for hardcoding separators. |
237 | | return quote(force_bytes(path.replace("\\", "/")), safe=b"/~!*()'") |
| 237 | return quote(force_bytes(path).replace(b"\\", b"/"), safe=b"/~!*()'") |
238 | 238 | |
239 | 239 | def get_system_encoding(): |
240 | 240 | """ |
diff --git a/tests/utils_tests/encoding.py b/tests/utils_tests/encoding.py
index d191845..7aaba25 100644
a
|
b
|
|
2 | 2 | from __future__ import unicode_literals |
3 | 3 | |
4 | 4 | from django.utils import unittest |
5 | | from django.utils.encoding import force_bytes |
| 5 | from django.utils.encoding import force_bytes, filepath_to_uri |
6 | 6 | |
7 | 7 | |
8 | 8 | class TestEncodingUtils(unittest.TestCase): |
… |
… |
class TestEncodingUtils(unittest.TestCase):
|
15 | 15 | exc = ValueError(error_msg) |
16 | 16 | result = force_bytes(exc) |
17 | 17 | self.assertEqual(result, error_msg.encode('utf-8')) |
| 18 | |
| 19 | def test_filepath_to_uri(self): |
| 20 | self.assertEqual(filepath_to_uri('upload\\чубака.mp4'), |
| 21 | 'upload/%D1%87%D1%83%D0%B1%D0%B0%D0%BA%D0%B0.mp4') |
| 22 | self.assertEqual(filepath_to_uri('upload\\чубака.mp4'.encode('utf-8')), |
| 23 | 'upload/%D1%87%D1%83%D0%B1%D0%B0%D0%BA%D0%B0.mp4') |