Skip to content

Commit

Permalink
fix(webscrobbler): Fix formatting of slug url in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Jun 17, 2024
1 parent bed8314 commit 67e5341
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/backend/sources/WebScrobblerSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -46,12 +47,12 @@ export class WebScrobblerSource extends MemorySource {
}

protected async doBuildInitData(): Promise<true | string | undefined> {
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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 67e5341

Please sign in to comment.