Skip to content

Commit 4a739d1

Browse files
authored
Force SourceSpan.url to be absolute in the JS API (#2298)
Partially addressed #3908
1 parent 54eef34 commit 4a739d1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## 1.78.0
22

3+
### JS API
4+
5+
* Fix a bug where accessing `SourceSpan.url` would crash when a relative URL was
6+
passed to the Sass API.
7+
38
### Embedded Sass
49

510
* Explicitly expose a `sass` executable from the `sass-embedded` npm package.

lib/src/js/source_span.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:path/path.dart' as p;
56
import 'package:source_span/source_span.dart';
67

78
import '../util/lazy_file_span.dart';
@@ -21,7 +22,8 @@ void updateSourceSpanPrototype() {
2122
getJSClass(item).defineGetters({
2223
'start': (FileSpan span) => span.start,
2324
'end': (FileSpan span) => span.end,
24-
'url': (FileSpan span) => span.sourceUrl.andThen(dartToJSUrl),
25+
'url': (FileSpan span) => span.sourceUrl.andThen((url) => dartToJSUrl(
26+
url.scheme == '' ? p.toUri(p.absolute(p.fromUri(url))) : url)),
2527
'text': (FileSpan span) => span.text,
2628
'context': (FileSpan span) => span.context,
2729
});

0 commit comments

Comments
 (0)