From f722340962867356557c340974182ad402b9eb1d Mon Sep 17 00:00:00 2001 From: Emma Date: Sun, 2 Oct 2022 19:38:01 -0400 Subject: [PATCH] Prevent adding extra `/` when concatenating locale paths (#2665) * Formatting the locales pathname to be more accurate Before this change, the URL would refer `https://localhost//static/locales/${locale}.json` which technically works in most web browsers, but it does not work in Cordova at all, so this changes the links to be more accurately: `https://localhost/static/locales/${locale}.json` * Removing usage of `path` because it requires a polyfill/shim * Linting the code --- src/renderer/i18n/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/i18n/index.js b/src/renderer/i18n/index.js index e7363103..95fca8f9 100644 --- a/src/renderer/i18n/index.js +++ b/src/renderer/i18n/index.js @@ -60,7 +60,7 @@ class CustomVueI18n extends VueI18n { } if (url.pathname) { - url.pathname += `/static/locales/${locale}.json` + url.pathname += `${!url.pathname.endsWith('/') ? '/' : ''}static/locales/${locale}.json` } else { url.pathname = `/static/locales/${locale}.json` }