@nuskin/ns-util 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/urlService.js +19 -1
package/package.json
CHANGED
package/src/urlService.js
CHANGED
|
@@ -82,6 +82,16 @@ function getLocaleFromUrl(url = window.location.href) {
|
|
|
82
82
|
if (locale) {
|
|
83
83
|
[language, country] = locale.split('_');
|
|
84
84
|
}
|
|
85
|
+
} else {
|
|
86
|
+
href_locale = url.match(/\/([a-z]|[A-Z]){2}\/([a-z]|[A-Z]){2}\//);
|
|
87
|
+
if (href_locale) {
|
|
88
|
+
locale = href_locale[0].substring(1, href_locale[0].length-1);
|
|
89
|
+
if (locale) {
|
|
90
|
+
[country, language] = locale.split('/');
|
|
91
|
+
country = country.toUpperCase();
|
|
92
|
+
locale = `${language}_${country.toUpperCase()}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
85
95
|
}
|
|
86
96
|
return locale ? [language, country, locale] : [];
|
|
87
97
|
|
|
@@ -93,7 +103,9 @@ function getLocaleFromUrl(url = window.location.href) {
|
|
|
93
103
|
* @returns {boolean}
|
|
94
104
|
*/
|
|
95
105
|
function isLocalePage() {
|
|
96
|
-
|
|
106
|
+
const url = window.location.href;
|
|
107
|
+
const lowerUrl = window.location.href.toLowerCase();
|
|
108
|
+
return url.includes(`/${getLocale()}/`) || lowerUrl.includes(`/${getEqLocale()}/`);
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
function isAuthor() {
|
|
@@ -129,6 +141,12 @@ function getLocale() {
|
|
|
129
141
|
return `${runConfig.language}_${runConfig.country}`;
|
|
130
142
|
}
|
|
131
143
|
|
|
144
|
+
function getEqLocale() {
|
|
145
|
+
let runConfig = RunConfigService.getRunConfig();
|
|
146
|
+
|
|
147
|
+
return `${runConfig.country.toLowerCase()}/${runConfig.language.toLowerCase()}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
function checkUrlForExtension(url) {
|
|
133
151
|
// only add .html to url path if it doesn't start with http or is the #
|
|
134
152
|
if (url && !url.startsWith("http") && "#" !== url && !url.includes(".html")) {
|