Skip to content

Commit 628772f

Browse files
committed
Properly handle Windows file: URLs on Node.js
This adds logic to the JS implementation of URI to determine whether the code is running on Windows under Node.js.
1 parent f78076d commit 628772f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,10 @@ class Uri {
602602
@patch
603603
class _Uri {
604604
@patch
605-
static bool get _isWindows => false;
605+
static bool get _isWindows => _isWindowsCached;
606+
607+
static final bool _isWindowsCached =
608+
JS('bool', 'process !== undefined && process.platform == "win32"');
606609

607610
// Matches a String that _uriEncodes to itself regardless of the kind of
608611
// component. This corresponds to [_unreservedTable], i.e. characters that

sdk/lib/_internal/js_runtime/lib/core_patch.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,10 @@ class Uri {
611611
@patch
612612
class _Uri {
613613
@patch
614-
static bool get _isWindows => false;
614+
static bool get _isWindows => _isWindowsCached;
615+
616+
static final bool _isWindowsCached =
617+
JS('bool', 'process !== undefined && process.platform == "win32"');
615618

616619
// Matches a String that _uriEncodes to itself regardless of the kind of
617620
// component. This corresponds to [_unreservedTable], i.e. characters that

0 commit comments

Comments
 (0)