Skip to content

Commit

Permalink
Sanitize URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed May 29, 2024
1 parent ec3590a commit 163c4eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hubs-backup-tool",
"productName": "Hubs Backup Tool",
"version": "1.0.5",
"version": "1.0.6",
"description": "Tool for backing up your assets from a Hubs instance",
"main": ".webpack/main",
"scripts": {
Expand Down
10 changes: 8 additions & 2 deletions src/api/reticulum-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ interface MediaWithCursorT {
probe?: boolean;
}

function sanitizedURL(url: string) {
return url.replace(/([^:]\/)\/+/g, "$1");
}

export class ReticulumApi {
options: ReticulumApiOptions;

Expand All @@ -152,15 +156,17 @@ export class ReticulumApi {
}

getUrl(path: string): string {
return `https://${this.options.host}${
const url = `https://${this.options.host}${
this.options.port ? ":" + this.options.port : ""
}/api/v1/${path}`;
return sanitizedURL(url);
}

getRoomObjectsUrl(hubId: string) {
return `https://${this.options.host}${
const url = `https://${this.options.host}${
this.options.port ? ":" + this.options.port : ""
}/${hubId}/objects.gltf`;
return sanitizedURL(url);
}

api(path: string, method = "GET", payload?: JSON): Promise<any> {
Expand Down

0 comments on commit 163c4eb

Please sign in to comment.