File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 6
6
relying on this bug, but if so they can simply add ` !global ` to the variable
7
7
declaration to preserve the old behavior.
8
8
9
+ * ** Potentially breaking bug fix:** Fix a bug where imports of root-relative
10
+ URLs (those that begin with ` / ` ) in ` @import ` rules would be passed to
11
+ both Dart and JS importers as ` file: ` URLs.
12
+
9
13
## 1.35.1
10
14
11
15
* Fix a bug where the quiet dependency flag didn't silence warnings in some
Original file line number Diff line number Diff line change @@ -1120,7 +1120,9 @@ abstract class StylesheetParser extends Parser {
1120
1120
String parseImportUrl (String url) {
1121
1121
// Backwards-compatibility for implementations that allow absolute Windows
1122
1122
// paths in imports.
1123
- if (p.windows.isAbsolute (url)) return p.windows.toUri (url).toString ();
1123
+ if (p.windows.isAbsolute (url) && ! p.url.isRootRelative (url)) {
1124
+ return p.windows.toUri (url).toString ();
1125
+ }
1124
1126
1125
1127
// Throw a [FormatException] if [url] is invalid.
1126
1128
Uri .parse (url);
Original file line number Diff line number Diff line change @@ -93,6 +93,27 @@ void main() {
93
93
''' ));
94
94
});
95
95
96
+ group ("the imported URL" , () {
97
+ // Regression test for #1137.
98
+ test ("isn't changed if it's root-relative" , () {
99
+ compileString ('@import "/orange";' , importers: [
100
+ TestImporter (expectAsync1 ((url) {
101
+ expect (url, equals (Uri .parse ("/orange" )));
102
+ return Uri .parse ("u:$url " );
103
+ }), (url) => ImporterResult ('' , syntax: Syntax .scss))
104
+ ]);
105
+ });
106
+
107
+ test ("is converted to a file: URL if it's an absolute Windows path" , () {
108
+ compileString ('@import "C:/orange";' , importers: [
109
+ TestImporter (expectAsync1 ((url) {
110
+ expect (url, equals (Uri .parse ("file:///C:/orange" )));
111
+ return Uri .parse ("u:$url " );
112
+ }), (url) => ImporterResult ('' , syntax: Syntax .scss))
113
+ ]);
114
+ });
115
+ });
116
+
96
117
test ("uses an importer's source map URL" , () {
97
118
late SingleMapping map;
98
119
compileString ('@import "orange";' ,
Original file line number Diff line number Diff line change @@ -364,6 +364,25 @@ void main() {
364
364
}))));
365
365
expect (result.stats.includedFiles, equals (['foo' ]));
366
366
});
367
+
368
+ // Regression test for #1137.
369
+ test ("isn't changed if it's root-relative" , () {
370
+ renderSync (RenderOptions (
371
+ data: "@import '/foo'" ,
372
+ importer: allowInterop (expectAsync2 ((url, _) {
373
+ expect (url, equals ('/foo' ));
374
+ return NodeImporterResult (contents: '' );
375
+ }))));
376
+ });
377
+
378
+ test ("is converted to a file: URL if it's an absolute Windows path" , () {
379
+ renderSync (RenderOptions (
380
+ data: "@import 'C:/foo'" ,
381
+ importer: allowInterop (expectAsync2 ((url, _) {
382
+ expect (url, equals ('file:///C:/foo' ));
383
+ return NodeImporterResult (contents: '' );
384
+ }))));
385
+ });
367
386
});
368
387
369
388
group ("the previous URL" , () {
You can’t perform that action at this time.
0 commit comments