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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgt-node-utils",
3
- "version": "1.2.64",
3
+ "version": "1.2.65",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
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 });