From 62590cc97632b6a25195da38b4a6ae2c5c823cc2 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Mon, 14 Dec 2020 07:45:45 -0800 Subject: [PATCH] getPathWithoutLanguage, remove split-slice-join pattern (#16914) Co-authored-by: Vanessa Yuen <6842965+vanessayuenn@users.noreply.github.com> --- lib/path-utils.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/path-utils.js b/lib/path-utils.js index 02e75aab1d26..1dcf9b543304 100644 --- a/lib/path-utils.js +++ b/lib/path-utils.js @@ -71,11 +71,7 @@ function getPathWithLanguage (href, languageCode) { // remove the language from the given HREF // /articles/foo -> /en/articles/foo function getPathWithoutLanguage (href) { - const newHref = href.match(patterns.hasLanguageCode) - ? '/' + href.split('/').slice(2).join('/') - : href - - return slash(newHref) + return slash(href.replace(patterns.hasLanguageCode, '/')) } function getPathWithoutVersion (href) {