Fix embedding source maps with non-ASCII characters (#471)

Closes #457
This commit is contained in:
Natalie Weizenbaum 2018-09-11 12:13:43 -07:00 committed by GitHub
parent ede9c81e0b
commit 1a5eb2a2e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View File

@ -3,6 +3,11 @@
* Properly generate source maps for stylesheets that emit `@charset`
declarations.
### Command-Line Interface
* Don't error out when passing `--embed-source-maps` along with
`--embed-sources` for stylesheets that contain non-ASCII characters.
## 1.13.2
* Properly parse `:nth-child()` and `:nth-last-child()` selectors with

View File

@ -142,7 +142,8 @@ String _writeSourceMap(
Uri url;
if (options.embedSourceMap) {
url = new Uri.dataFromString(sourceMapText, mimeType: 'application/json');
url = new Uri.dataFromString(sourceMapText,
mimeType: 'application/json', encoding: utf8);
} else {
var sourceMapPath = destination + '.map';
ensureDir(p.dirname(sourceMapPath));

View File

@ -1,5 +1,5 @@
name: sass
version: 1.13.3-dev
version: 1.13.3
description: A Sass implementation in Dart.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/sass/dart-sass

View File

@ -274,6 +274,23 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
test("doesn't generate a source map file", () async {
await d.nothing("out.css.map").validate();
});
// Regression test for #457.
test("--embed-sources works with non-ASCII characters", () async {
await d.file("test.scss", "a {b: '▼'}").create();
await (await runSass([
"--embed-source-map",
"--embed-sources",
"test.scss",
"out.css"
]))
.shouldExit(0);
var css = readFile(d.path("out.css"));
map = embeddedSourceMap(css);
expect(map, containsPair("sources", ["test.scss"]));
expect(map, containsPair("sourcesContent", ["a {b: '▼'}"]));
});
});
group("with the target in a different directory", () {