diff --git a/src/client.js b/src/client.js index 0d162369..d821d8f2 100644 --- a/src/client.js +++ b/src/client.js @@ -60,8 +60,9 @@ export class Client { * @param {ClientOptions} [options] An object providing values to initialize this instance. */ constructor(apiKey, blog, options = {}) { + const baseUrl = options.baseUrl ?? "https://rest.akismet.com"; this.apiKey = apiKey; - this.baseUrl = new URL(options.baseUrl ?? "https://rest.akismet.com/"); + this.baseUrl = new URL(baseUrl.slice(-1) == "/" ? baseUrl : `${baseUrl}/`); this.blog = blog; this.isTest = options.isTest ?? false; this.userAgent = options.userAgent ?? `Node.js/${version.slice(1)} | Akismet/${Client.#version}`;