mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 06:48:47 +00:00
Update api-helpers.js
This commit is contained in:
parent
a5bdfd92d7
commit
63b9d395dd
1 changed files with 3 additions and 2 deletions
|
@ -2,10 +2,11 @@ export function formatApiCall(url, args) {
|
||||||
const find = /\{.*?\}/g;
|
const find = /\{.*?\}/g;
|
||||||
const replace = (match) => {
|
const replace = (match) => {
|
||||||
const key = match.replace(/\{|\}/g, "");
|
const key = match.replace(/\{|\}/g, "");
|
||||||
|
let value = args[key];
|
||||||
if (key === "url") {
|
if (key === "url") {
|
||||||
args[key] = args[key].replace(/\/+$/, ""); // remove trailing slashes
|
value = value.replace(/\/+$/, ""); // remove trailing slashes
|
||||||
}
|
}
|
||||||
return args[key] || "";
|
return value || "";
|
||||||
};
|
};
|
||||||
|
|
||||||
return url.replace(find, replace).replace(find, replace);
|
return url.replace(find, replace).replace(find, replace);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue