Skip to content

Commit d8b087f

Browse files
committed
tidy: improve setting of a map's url.
1 parent 8766d81 commit d8b087f

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/flatmap.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import {FLATMAP_LEGEND} from './legend'
5959
import type {FlatmapLegendEntry} from './legend'
6060
import {UserInteractions} from './interactions'
6161
import {MapTermGraph} from './knowledge'
62-
import {KNOWLEDGE_SOURCE_SCHEMA, FlatMapServer} from './mapserver'
62+
import {KNOWLEDGE_SOURCE_SCHEMA, type FlatMapServer, SERVER_FLATMAP_RESOURCE} from './mapserver'
6363
import {loadMarkerIcons} from './markers'
6464
import {APINATOMY_PATH_PREFIX, type PathType} from './pathways'
6565
import {SearchIndex} from './search'
@@ -258,7 +258,7 @@ export class FlatMap
258258
this.#mapServer = mapServer
259259
this.#baseUrl = mapServer.url()
260260
this.#id = mapDescription.id
261-
this.#url = `${this.#baseUrl}flatmap/${mapDescription.uuid}`
261+
this.#url = `${this.#baseUrl}${SERVER_FLATMAP_RESOURCE}${mapDescription.uuid}`
262262
this.#uuid = mapDescription.uuid
263263
this.#details = mapDescription.details
264264
this.#mapMetadata = mapDescription.mapMetadata
@@ -760,8 +760,8 @@ export class FlatMap
760760
}
761761
}
762762

763-
makeServerUrl(url, resource='flatmap/'): string
764-
//==============================================
763+
makeServerUrl(url, resource=SERVER_FLATMAP_RESOURCE): string
764+
//==========================================================
765765
{
766766
if (url.startsWith('http://') || url.startsWith('https://')) {
767767
return url
@@ -849,11 +849,7 @@ export class FlatMap
849849
get url()
850850
//========
851851
{
852-
const url = this.makeServerUrl('')
853-
if (url.endsWith('/')) {
854-
return url.substring(0, url.length - 1)
855-
}
856-
return url
852+
return this.#url
857853
}
858854

859855
/**

src/mapserver.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ type KnowledgeSourcesRecord = {
4646

4747
//==============================================================================
4848

49+
export const SERVER_FLATMAP_RESOURCE = 'flatmap/'
50+
51+
//==============================================================================
52+
4953
export class FlatMapServer
5054
{
5155
#url: string

0 commit comments

Comments
 (0)