@smpx/koa-request 0.4.1 → 0.4.3

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.
Files changed (2) hide show
  1. package/Request.js +4 -4
  2. package/package.json +1 -1
package/Request.js CHANGED
@@ -399,8 +399,8 @@ class Request {
399
399
  this.ctx.set('Content-Security-Policy', `frame-ancestors https://*.${domain}`);
400
400
  }
401
401
 
402
+ this.handlePlatformModification();
402
403
  if (!this.isAjax()) {
403
- this.handlePlatformModification();
404
404
  this.setUTMCookie();
405
405
  this.setAffidCookie();
406
406
  this.handleFlashMessage();
@@ -1260,7 +1260,7 @@ class Request {
1260
1260
  let host = refererUri.hostname;
1261
1261
  const baseDomain = this.baseDomain();
1262
1262
 
1263
- if (host.endsWith(baseDomain)) {
1263
+ if (host.endsWith(baseDomain) || /^(?:direct|localhost|127|192|172|10)\b/.test(host)) {
1264
1264
  return {
1265
1265
  name: host,
1266
1266
  source: host,
@@ -1404,8 +1404,8 @@ class Request {
1404
1404
 
1405
1405
  handlePlatformModification() {
1406
1406
  let setPlatformCookie = false;
1407
- if (!this.isMobileApp()) {
1408
- // don't change platform in mobile apps from query or cookie
1407
+ if (!this.isMobileApp() && !this.isAjax()) {
1408
+ // don't change platform in mobile apps (and ajax requests) from query or cookie
1409
1409
  const platform = this.ctx.query[PLATFORM_PARAM] || this.cookie(PLATFORM_COOKIE);
1410
1410
  setPlatformCookie = this.setPlatform(platform);
1411
1411
  if (setPlatformCookie) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smpx/koa-request",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Handle basic tasks for koajs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",