Skip to content

Commit 20cf920

Browse files
committed
[GR-64032] Allow non-file URLs in uriToURL on SVM.
PullRequest: js/3476
2 parents 1089202 + de9258e commit 20cf920

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

graal-js/mx.graal-js/truffle.tck.permissions/js_excludes.json

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
}
2929
]
3030
},
31+
{
32+
"name" : "com.oracle.truffle.js.runtime.objects.DefaultESModuleLoader",
33+
"methods" : [
34+
{ "name" : "uriToURL",
35+
"justification" : "URI to URL conversion without URLStreamHandler. Only privileged call with URLStreamHandler."
36+
}
37+
]
38+
},
3139
{
3240
"name" : "com.oracle.truffle.js.runtime.util.DebugJSAgent",
3341
"methods" : [

graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/regress/GR32763.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -60,8 +60,8 @@ public void testUnknownImportUrl() throws IOException {
6060
}
6161

6262
@Test
63-
public void testSchemeNotSupported() throws IOException {
64-
assertErrorMessage("foo://bar.mjs", "Error: Unsupported URI scheme foo");
63+
public void testUnknownProtocol() throws IOException {
64+
assertErrorMessage("foo://bar.mjs", "Error: unknown protocol: foo");
6565
}
6666

6767
private static void assertErrorMessage(String importUrl, String expected) throws IOException {

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/objects/DefaultESModuleLoader.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import com.oracle.truffle.api.strings.TruffleString;
6666
import com.oracle.truffle.js.lang.JavaScriptLanguage;
6767
import com.oracle.truffle.js.runtime.Errors;
68-
import com.oracle.truffle.js.runtime.JSConfig;
6968
import com.oracle.truffle.js.runtime.JSException;
7069
import com.oracle.truffle.js.runtime.JSRealm;
7170
import com.oracle.truffle.js.runtime.Strings;
@@ -260,13 +259,7 @@ protected AbstractModuleRecord loadModuleFromURL(ScriptOrModule referrer, Module
260259
}
261260

262261
private static URL uriToURL(URI moduleURI) throws MalformedURLException {
263-
if (!JSConfig.SubstrateVM) {
264-
try {
265-
return moduleURI.toURL();
266-
} catch (MalformedURLException e) {
267-
}
268-
}
269-
throw new MalformedURLException("Unsupported URI scheme " + moduleURI.getScheme());
262+
return moduleURI.toURL();
270263
}
271264

272265
protected AbstractModuleRecord loadModuleFromFile(ScriptOrModule referrer, ModuleRequest moduleRequest, TruffleFile moduleFile, String maybeCanonicalPath) throws IOException {

0 commit comments

Comments
 (0)