Skip to content

Commit b684e7b

Browse files
committed
fix(runtime): never report an http(s) module URL as a file:// URL
ReportedModuleUrl tested for a URL scheme before asking whether the string is an http(s) URL, so one the loader accepts with leading whitespace or C0 controls failed the scheme test and was prefixed with file://. It now spells http(s) URLs first; other inputs are reported as before.
1 parent e6b5bf0 commit b684e7b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎NativeScript/runtime/ModuleUrl.cpp‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,15 @@ std::string ReportedModuleUrl(const std::string& keyOrPath) {
141141
if (keyOrPath.empty()) {
142142
return "file:///app/";
143143
}
144+
// Before the scheme test: the loader reads strings as http(s) URLs that the
145+
// scheme test rejects (leading whitespace), and those must never be
146+
// prefixed with file://.
147+
const std::string http = NormalizeHttpModuleUrl(keyOrPath);
148+
if (!http.empty()) {
149+
return http;
150+
}
144151
if (HasUrlScheme(keyOrPath)) {
145-
const std::string http = NormalizeHttpModuleUrl(keyOrPath);
146-
return http.empty() ? keyOrPath : http;
152+
return keyOrPath;
147153
}
148154
// Every occurrence, as tns::ReplaceAll removes it everywhere else.
149155
std::string path = keyOrPath;

0 commit comments

Comments
 (0)