diff --git a/src/backend/sources/WebScrobblerSource.ts b/src/backend/sources/WebScrobblerSource.ts index fa1b0d15..a95dd8b2 100644 --- a/src/backend/sources/WebScrobblerSource.ts +++ b/src/backend/sources/WebScrobblerSource.ts @@ -15,6 +15,7 @@ import { WebScrobblerPayload, WebScrobblerSong } from "../common/vendor/webscrobbler/interfaces.js"; +import { joinedUrl } from "../utils.js"; import MemorySource from "./MemorySource.js"; export class WebScrobblerSource extends MemorySource { @@ -46,12 +47,12 @@ export class WebScrobblerSource extends MemorySource { } protected async doBuildInitData(): Promise { - this.logger.info(`Accepting requests at ${this.localUrl.toString()}/api/webscrobbler${this.config.data.slug === undefined ? '' : `/${this.config.data.slug}`}`); + this.logger.info(`Accepting requests at ${joinedUrl(this.localUrl, 'api/webscrobbler', this.config.data.slug ?? '')}`); return true; } matchSlug(slug: string | undefined) { - if (this.config.data.slug === undefined || this.config.data.slug === null) { + if (this.config.data.slug === undefined) { return slug === undefined; } diff --git a/src/backend/utils.ts b/src/backend/utils.ts index 2bfb3735..0ffd92f2 100644 --- a/src/backend/utils.ts +++ b/src/backend/utils.ts @@ -787,6 +787,6 @@ export const generateBaseURL = (userUrl: string | undefined, defaultPort: number export const joinedUrl = (url: URL, ...paths: string[]): URL => { // https://github.com/jfromaniello/url-join#in-nodejs const finalUrl = new URL(url); - finalUrl.pathname = joinPath(url.pathname, ...paths); + finalUrl.pathname = joinPath(url.pathname, ...(paths.filter(x => x.trim() !== ''))); return finalUrl; }