Reverting changes regarding single quotes

This commit is contained in:
David Négrier
2021-07-23 14:59:56 +02:00
parent a146065cc6
commit 3d5c222957
6 changed files with 401 additions and 401 deletions
+18 -18
View File
@@ -1,6 +1,6 @@
import Axios from 'axios';
import { PUSHER_URL } from '../Enum/EnvironmentVariable';
import type { CharacterTexture } from './LocalUser';
import Axios from "axios";
import { PUSHER_URL } from "../Enum/EnvironmentVariable";
import type { CharacterTexture } from "./LocalUser";
export class MapDetail {
constructor(public readonly mapUrl: string, public readonly textures: CharacterTexture[] | undefined) {}
@@ -15,19 +15,19 @@ export class Room {
private _search: URLSearchParams;
constructor(id: string) {
const url = new URL(id, 'https://example.com');
const url = new URL(id, "https://example.com");
this.id = url.pathname;
if (this.id.startsWith('/')) {
if (this.id.startsWith("/")) {
this.id = this.id.substr(1);
}
if (this.id.startsWith('_/')) {
if (this.id.startsWith("_/")) {
this.isPublic = true;
} else if (this.id.startsWith('@/')) {
} else if (this.id.startsWith("@/")) {
this.isPublic = false;
} else {
throw new Error('Invalid room ID');
throw new Error("Invalid room ID");
}
this._search = new URLSearchParams(url.search);
@@ -38,16 +38,16 @@ export class Room {
baseUrl: string,
currentInstance: string
): { roomId: string; hash: string | null } {
let roomId = '';
let roomId = "";
let hash = null;
if (!identifier.startsWith('/_/') && !identifier.startsWith('/@/')) {
if (!identifier.startsWith("/_/") && !identifier.startsWith("/@/")) {
//relative file link
//Relative identifier can be deep enough to rewrite the base domain, so we cannot use the variable 'baseUrl' as the actual base url for the URL objects.
//We instead use 'workadventure' as a dummy base value.
const baseUrlObject = new URL(baseUrl);
const absoluteExitSceneUrl = new URL(
identifier,
'http://workadventure/_/' + currentInstance + '/' + baseUrlObject.hostname + baseUrlObject.pathname
"http://workadventure/_/" + currentInstance + "/" + baseUrlObject.hostname + baseUrlObject.pathname
);
roomId = absoluteExitSceneUrl.pathname; //in case of a relative url, we need to create a public roomId
roomId = roomId.substring(1); //remove the leading slash
@@ -58,7 +58,7 @@ export class Room {
}
} else {
//absolute room Id
const parts = identifier.split('#');
const parts = identifier.split("#");
roomId = parts[0];
roomId = roomId.substring(1); //remove the leading slash
if (parts.length > 1) {
@@ -78,7 +78,7 @@ export class Room {
if (this.isPublic) {
const match = /_\/[^/]+\/(.+)/.exec(this.id);
if (!match) throw new Error('Could not extract url from "' + this.id + '"');
this.mapUrl = window.location.protocol + '//' + match[1];
this.mapUrl = window.location.protocol + "//" + match[1];
resolve(new MapDetail(this.mapUrl, this.textures));
return;
} else {
@@ -89,7 +89,7 @@ export class Room {
params: urlParts,
})
.then(({ data }) => {
console.log('Map ', this.id, ' resolves to URL ', data.mapUrl);
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
resolve(data);
return;
})
@@ -118,7 +118,7 @@ export class Room {
} else {
const match = /@\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
if (!match) throw new Error('Could not extract instance from "' + this.id + '"');
this.instance = match[1] + '/' + match[2];
this.instance = match[1] + "/" + match[2];
return this.instance;
}
}
@@ -127,7 +127,7 @@ export class Room {
const regex = /@\/([^/]+)\/([^/]+)(?:\/([^/]*))?/gm;
const match = regex.exec(url);
if (!match) {
throw new Error('Invalid URL ' + url);
throw new Error("Invalid URL " + url);
}
const results: { organizationSlug: string; worldSlug: string; roomSlug?: string } = {
organizationSlug: match[1],
@@ -140,8 +140,8 @@ export class Room {
}
public isDisconnected(): boolean {
const alone = this._search.get('alone');
if (alone && alone !== '0' && alone.toLowerCase() !== 'false') {
const alone = this._search.get("alone");
if (alone && alone !== "0" && alone.toLowerCase() !== "false") {
return true;
}
return false;