Remove base url from sample server and properly handle url schemes

This commit is contained in:
Aria 2025-11-20 12:46:29 -06:00 committed by W-A-James
parent 9fdba6374c
commit d70b758065
No known key found for this signature in database
GPG key ID: 2CE8DBC07DABE749
4 changed files with 16 additions and 6 deletions

View file

@ -113,4 +113,14 @@ export function getCommonSampleInfo(hapValue, bank) {
/** Selects entries from `source` and renames them via `map` */
export const pickAndRename = (source, map) => {
return Object.fromEntries(Object.entries(map).map(([newKey, oldKey]) => [newKey, source[oldKey]]));
}
export const getBaseURL = (url) => {
try {
// For real URLs
return new URL('.', new URL(url)).href.replace(/\/$/, ''); // removes trailing slash
} catch {
// For pseudo URLS
return url.split('/').slice(0, -1).join('/');
}
};