wgt-node-utils 1.2.64 → 1.2.66

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.66",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -161,6 +161,20 @@ class wgtNodeUtils {
161
161
  }
162
162
  }
163
163
 
164
+ getVideoDomainByHostname = (hostname, ENV) => {
165
+ let self = this;
166
+ let needReplaceArr = ['pro', 'qa', 'dev', 'test', 'development'];
167
+ if (needReplaceArr.includes(ENV)) {
168
+ if (ENV === 'qa' || ENV === 'test') {
169
+ return `//video.test-static.beesads.com/game_video`
170
+ }
171
+ return `//video.enjoy4fun.com`;
172
+ } else {
173
+ const mainDomain = self.getMainDomainByHostname(hostname);
174
+ return `//video.${mainDomain}`;
175
+ }
176
+ };
177
+
164
178
  /***
165
179
  * 通用头信息添加
166
180
  * @res node端 返回头
@@ -963,11 +977,11 @@ class wgtNodeUtils {
963
977
  * @param {Array} languageList - 语言列表
964
978
  * @param {string} url - 页面URL
965
979
  */
966
- renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
980
+ renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
967
981
  const languageLinkList = languageList.map(item => ({
968
982
  rel: 'alternate',
969
983
  hrefLang: item.code === 'en' ? 'en' : item.code,
970
- href: item.code === 'en' ? pathWithoutLang : url
984
+ href: item.code === 'en' ? pathWithoutLang : url.replace(/(https?:\/\/[^/]+)\/en(?=\/|$)/, `$1/${item.code}`)
971
985
  }));
972
986
  languageLinkList.push({ rel: 'alternate', hrefLang: 'x-default', href: pathWithoutLang });
973
987
  languageLinkList.push({ rel: 'canonical', href: pathWithoutLang });