From 00639dbd6d023aaba20efa5497988cd730923633 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 3 Jun 2022 12:04:59 +0100 Subject: [PATCH] Refs #33765 -- Added tests for trailing whitespace in JavaScript source map references. --- .../cached/source_map_trailing_whitespace.js | 2 ++ tests/staticfiles_tests/test_storage.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js diff --git a/tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js b/tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js new file mode 100644 index 0000000000..e15bc402a9 --- /dev/null +++ b/tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js @@ -0,0 +1,2 @@ +//# sourceMappingURL=source_map.js.map +let a_variable = 1; diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index 3783d32872..745094acf6 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -280,6 +280,20 @@ class TestHashedFiles: ) self.assertPostCondition() + def test_js_source_map_trailing_whitespace(self): + relpath = self.hashed_file_path("cached/source_map_trailing_whitespace.js") + self.assertEqual( + relpath, "cached/source_map_trailing_whitespace.cd45b8534a87.js" + ) + with storage.staticfiles_storage.open(relpath) as relfile: + content = relfile.read() + self.assertNotIn(b"//# sourceMappingURL=source_map.js.map\t ", content) + self.assertIn( + b"//# sourceMappingURL=source_map.js.99914b932bd3.map", + content, + ) + self.assertPostCondition() + def test_js_source_map_sensitive(self): relpath = self.hashed_file_path("cached/source_map_sensitive.js") self.assertEqual(relpath, "cached/source_map_sensitive.5da96fdd3cb3.js")