From 340f256074725c1f3b60b651868956dec3d37f12 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 26 Dec 2024 17:21:14 +0100 Subject: [PATCH] Fix: fix #5 --- package.json | 2 +- src/OsmUserInfo.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4c6f879..e518d9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mastodon-bot", - "version": "0.0.4", + "version": "0.0.5", "author": "Pietervdvn", "license": "GPL", "description": "Experimenting with mastodon-bot", diff --git a/src/OsmUserInfo.ts b/src/OsmUserInfo.ts index 67983b9..0c5a70e 100644 --- a/src/OsmUserInfo.ts +++ b/src/OsmUserInfo.ts @@ -68,7 +68,12 @@ export default class OsmUserInfo { return undefined } - const url = new URL(mastodonLinks[0]) + let mastodonlink = mastodonLinks[0] + while(mastodonlink.endsWith("/")){ + mastodonlink = mastodonlink.substring(0, mastodonlink.length - 1) + } + + const url = new URL(mastodonlink) const username = url.pathname.split("/").at(-1) + (url.host === mastodonApi.hostname ? "" : "@" + url.host) if (await mastodonApi.hasNoBot(username)) {