wgt-node-utils 1.2.64 → 1.2.65
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +2 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -963,11 +963,11 @@ class wgtNodeUtils {
|
|
|
963
963
|
* @param {Array} languageList - 语言列表
|
|
964
964
|
* @param {string} url - 页面URL
|
|
965
965
|
*/
|
|
966
|
-
renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
|
|
966
|
+
renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
|
|
967
967
|
const languageLinkList = languageList.map(item => ({
|
|
968
968
|
rel: 'alternate',
|
|
969
969
|
hrefLang: item.code === 'en' ? 'en' : item.code,
|
|
970
|
-
href: item.code === 'en' ? pathWithoutLang : url
|
|
970
|
+
href: item.code === 'en' ? pathWithoutLang : url.replace(/(https?:\/\/[^/]+)\/en(?=\/|$)/, `$1/${item.code}`)
|
|
971
971
|
}));
|
|
972
972
|
languageLinkList.push({ rel: 'alternate', hrefLang: 'x-default', href: pathWithoutLang });
|
|
973
973
|
languageLinkList.push({ rel: 'canonical', href: pathWithoutLang });
|