Skip to content

Commit 255cd66

Browse files
authoredJun 23, 2022
fix(compiler): handle null window.location.origin (#2813)
when using a data URI or file URI (#2582), or when using iframe's `srcdoc`, the value for window.location.origin can be `null`. in these particular cases, passing `null` to `new URL(url, null)` will throw the following error: "Failed to construct 'URL': Invalid base URL"
1 parent 4656dce commit 255cd66

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/compiler/output-targets/dist-lazy/generate-system.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const getSystemLoader = async (
102102
103103
var resourcesUrl = scriptElm ? scriptElm.getAttribute('data-resources-url') || scriptElm.src : '';
104104
var start = function() {
105-
var url = new URL('${corePath}', new URL(resourcesUrl, window.location.origin));
105+
// if src is not present then origin is "null", and new URL() throws TypeError: Failed to construct 'URL': Invalid base URL
106+
var url = new URL('${corePath}', new URL(resourcesUrl, window.location.origin !== 'null' ? window.location.origin : undefined));
106107
System.import(url.href);
107108
};
108109

0 commit comments

Comments
 (0)
Please sign in to comment.