Skip to content

Commit

Permalink
perf: optimize regex and remove unnecessary regex
Browse files Browse the repository at this point in the history
  • Loading branch information
WillianAgostini committed Dec 26, 2023
1 parent fd4f547 commit ae9f303
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/helpers/combineURLs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
export default function combineURLs(baseURL, relativeURL) {
if (!relativeURL) return baseURL;

const baseURLRegex = new RegExp(/\/+$/);
const baseURLRegex = new RegExp(/\/?\/$/);
const relativeURLRegex = new RegExp(/^\/+/);
const multipleSlashes = new RegExp(/\/{3,}/g);
return baseURL.replace(multipleSlashes, '/').replace(baseURLRegex, '')
+ '/'
+ relativeURL.replace(multipleSlashes, '/').replace(relativeURLRegex, '');
+ relativeURL.replace(relativeURLRegex, '');
}

0 comments on commit ae9f303

Please sign in to comment.