From 10fbd679664c533e8a5fa45afb1f56ac945d8cfa Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Wed, 29 Apr 2020 19:54:55 +0200 Subject: [PATCH] fix: remove leading slash when using prefixUrl (#96) --- lib/plugin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/plugin.js b/lib/plugin.js index 614333d..e47325d 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -82,7 +82,10 @@ for (let method of ['get', 'head', 'delete', 'post', 'put', 'patch']) { if (/^https?/.test(url)) { delete _options.prefixUrl - } + } else if (_options.prefixUrl && typeof url === 'string' && url.startsWith('/')) { + // Prevents `ky` from throwing "`input` must not begin with a slash when using `prefixUrl`" + url = url.substr(1) + } try { const response = await this._ky[method](url, _options)