mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-08-28 20:08:18 +00:00
fix(nomadnet): parse backtick-separated parameters in download URLs
This commit is contained in:
@@ -1938,10 +1938,20 @@ export default {
|
||||
}
|
||||
|
||||
const queryIndex = path.indexOf("?");
|
||||
const backtickIndex = path.indexOf("`");
|
||||
let separatorIndex = -1;
|
||||
if (queryIndex >= 0 && backtickIndex >= 0) {
|
||||
separatorIndex = Math.min(queryIndex, backtickIndex);
|
||||
} else if (queryIndex >= 0) {
|
||||
separatorIndex = queryIndex;
|
||||
} else if (backtickIndex >= 0) {
|
||||
separatorIndex = backtickIndex;
|
||||
}
|
||||
|
||||
return {
|
||||
destination_hash: null, // node hash was not in provided url
|
||||
path: queryIndex >= 0 ? path.substring(0, queryIndex) : path,
|
||||
query: queryIndex >= 0 ? path.substring(queryIndex + 1) : null,
|
||||
path: separatorIndex >= 0 ? path.substring(0, separatorIndex) : path,
|
||||
query: separatorIndex >= 0 ? path.substring(separatorIndex + 1) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1954,10 +1964,20 @@ export default {
|
||||
if (destinationHash.length === 32) {
|
||||
const joined = relativeUrl.join(":");
|
||||
const queryIndex = joined.indexOf("?");
|
||||
const backtickIndex = joined.indexOf("`");
|
||||
let separatorIndex = -1;
|
||||
if (queryIndex >= 0 && backtickIndex >= 0) {
|
||||
separatorIndex = Math.min(queryIndex, backtickIndex);
|
||||
} else if (queryIndex >= 0) {
|
||||
separatorIndex = queryIndex;
|
||||
} else if (backtickIndex >= 0) {
|
||||
separatorIndex = backtickIndex;
|
||||
}
|
||||
|
||||
return {
|
||||
destination_hash: destinationHash,
|
||||
path: queryIndex >= 0 ? joined.substring(0, queryIndex) : joined,
|
||||
query: queryIndex >= 0 ? joined.substring(queryIndex + 1) : null,
|
||||
path: separatorIndex >= 0 ? joined.substring(0, separatorIndex) : joined,
|
||||
query: separatorIndex >= 0 ? joined.substring(separatorIndex + 1) : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user