Skip to content

Commit

Permalink
fix: remove traling slash from apiURL if present (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
Izumiko authored Jan 5, 2025
1 parent 6f24e39 commit cc31483
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/background-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ async function openLibraries() {
async function removeBookmark() {
const tab = await getCurrentTab();
const config = await getExtensionConfig();
const apiURL = new URL(`${config.server}/api/bookmarks/ext`).toString();
const srvURL = new URL(config.server);
srvURL.pathname = srvURL.pathname.replace(/\/+$/, '') + '/';
const apiURL = new URL(`${srvURL}api/bookmarks/ext`).toString();

const response = await fetch(apiURL, {
method: "DELETE",
Expand All @@ -128,7 +130,9 @@ async function saveBookmark(tags) {
const tab = await getCurrentTab();
const config = await getExtensionConfig();
const content = await getPageContent(tab);
const apiURL = new URL(`${config.server}/api/bookmarks/ext`).toString();
const srvURL = new URL(config.server);
srvURL.pathname = srvURL.pathname.replace(/\/+$/, '') + '/';
const apiURL = new URL(`${srvURL}api/bookmarks/ext`).toString();

const response = await fetch(apiURL, {
method: "POST",
Expand Down

0 comments on commit cc31483

Please sign in to comment.