diff --git a/sasstests.py b/sasstests.py index 8fd204d4..70ff9eac 100644 --- a/sasstests.py +++ b/sasstests.py @@ -752,6 +752,32 @@ def test_wsgi_sass_middleware_without_extension(self): self.assertEqual(expected.encode(), r.data) assert r.mimetype == 'text/css' + def test_wsgi_sass_middleware_without_extension_sass(self): + with tempdir() as css_dir: + src_dir = os.path.join(css_dir, 'src') + os.makedirs(src_dir) + with open(os.path.join(src_dir, 'a.sass'), 'w') as f: + f.write('a\n\tb\n\t\tcolor: blue;') + app = SassMiddleware( + self.sample_wsgi_app, { + __name__: { + 'sass_path': src_dir, + 'css_path': css_dir, + 'wsgi_path': '/static', + 'strip_extension': True, + }, + }, + ) + client = Client(app, Response) + r = client.get('/static/a.css') + assert r.status_code == 200 + expected = ( + 'a b {\n color: blue; }\n\n' + '/*# sourceMappingURL=../a.css.map */' + ) + self.assertEqual(expected.encode(), r.data) + assert r.mimetype == 'text/css' + class DistutilsTestCase(BaseTestCase): diff --git a/sassutils/builder.py b/sassutils/builder.py index 29e48786..4af08928 100644 --- a/sassutils/builder.py +++ b/sassutils/builder.py @@ -199,8 +199,14 @@ def unresolve_filename(self, filename): """ filename, _ = os.path.splitext(filename) if self.strip_extension: - filename = filename + '.scss' - return filename + for ext in ('.scss', '.sass'): + test_path = os.path.join(self.sass_path, filename + ext) + if os.path.exists(test_path): + return filename + ext + else: # file not found, let it error with `.scss` extension + return filename + '.scss' + else: + return filename def build(self, package_dir, output_style='nested'): """Builds the Sass/SCSS files in the specified :attr:`sass_path`.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: