Skip to content

Commit f0c9df3

Browse files
authored
fix: http realm cache key with query params (#328)
1 parent b14392e commit f0c9df3

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

NativeScript/runtime/HMRSupport.mm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,29 @@ void InitializeImportMetaHot(v8::Isolate* isolate,
193193
if (query.empty()) return originAndPath;
194194

195195
if (isAppMod) {
196-
return originAndPath;
196+
// Treat query params as part of module identity (browser-like),
197+
// but ignore internal `import` markers.
198+
std::vector<std::string> kept;
199+
size_t start = 0;
200+
while (start <= query.size()) {
201+
size_t amp = query.find('&', start);
202+
std::string pair = (amp == std::string::npos) ? query.substr(start) : query.substr(start, amp - start);
203+
if (!pair.empty()) {
204+
size_t eq = pair.find('=');
205+
std::string name = (eq == std::string::npos) ? pair : pair.substr(0, eq);
206+
if (!(name == "import")) kept.push_back(pair);
207+
}
208+
if (amp == std::string::npos) break;
209+
start = amp + 1;
210+
}
211+
if (kept.empty()) return originAndPath;
212+
std::sort(kept.begin(), kept.end());
213+
std::string rebuilt = originAndPath + "?";
214+
for (size_t i = 0; i < kept.size(); i++) {
215+
if (i > 0) rebuilt += "&";
216+
rebuilt += kept[i];
217+
}
218+
return rebuilt;
197219
}
198220

199221
if (isRt || isCore) {

0 commit comments

Comments
 (0)