Fix linter
This commit is contained in:
parent
45a2721c5c
commit
a2c750dea2
@ -21,14 +21,14 @@ export class Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getMapUrl(): Promise<string> {
|
public async getMapUrl(): Promise<string> {
|
||||||
return new Promise<string>(async (resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
if (this.mapUrl !== undefined) {
|
if (this.mapUrl !== undefined) {
|
||||||
resolve(this.mapUrl);
|
resolve(this.mapUrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isPublic) {
|
if (this.isPublic) {
|
||||||
const match = /_\/[^\/]+\/(.+)/.exec(this.id)
|
const match = /_\/[^/]+\/(.+)/.exec(this.id);
|
||||||
if (!match) throw new Error('Could not extract url from "'+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(this.mapUrl);
|
resolve(this.mapUrl);
|
||||||
@ -37,24 +37,25 @@ export class Room {
|
|||||||
// We have a private ID, we need to query the map URL from the server.
|
// We have a private ID, we need to query the map URL from the server.
|
||||||
const urlParts = this.parsePrivateUrl(this.id);
|
const urlParts = this.parsePrivateUrl(this.id);
|
||||||
|
|
||||||
const data:any = await Axios.get(`${API_URL}/map`, {
|
Axios.get(`${API_URL}/map`, {
|
||||||
params: urlParts
|
params: urlParts
|
||||||
|
}).then(({data}) => {
|
||||||
|
console.log('Map ', this.id, ' resolves to URL ', data.mapUrl);
|
||||||
|
resolve(data.mapUrl);
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Map ', this.id, ' resolves to URL ', data.data.mapUrl);
|
|
||||||
resolve(data.data.mapUrl);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private parsePrivateUrl(url: string): { organizationSlug: string, worldSlug: string, roomSlug?: string } {
|
private parsePrivateUrl(url: string): { organizationSlug: string, worldSlug: string, roomSlug?: string } {
|
||||||
const regex = /@\/([^\/]+)\/([^\/]+)(?:\/([^\/]*))?/gm;
|
const regex = /@\/([^/]+)\/([^/]+)(?:\/([^/]*))?/gm;
|
||||||
const match = regex.exec(url);
|
const match = regex.exec(url);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
throw new Error('Invalid URL '+url);
|
throw new Error('Invalid URL '+url);
|
||||||
}
|
}
|
||||||
let results: { organizationSlug: string, worldSlug: string, roomSlug?: string } = {
|
const results: { organizationSlug: string, worldSlug: string, roomSlug?: string } = {
|
||||||
organizationSlug: match[1],
|
organizationSlug: match[1],
|
||||||
worldSlug: match[2],
|
worldSlug: match[2],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user