@smpx/koa-request 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/Request.js +17 -10
  2. package/package.json +1 -1
package/Request.js CHANGED
@@ -1403,16 +1403,23 @@ class Request {
1403
1403
  }
1404
1404
 
1405
1405
  handlePlatformModification() {
1406
- // don't change platform in mobile apps
1407
- if (this.isMobileApp()) return;
1408
-
1409
- const platform = this.ctx.query[PLATFORM_PARAM] || this.cookie(PLATFORM_COOKIE);
1410
- const setPlatformCookie = this.setPlatform(platform);
1411
- if (setPlatformCookie) {
1412
- this.cookie(PLATFORM_COOKIE, platform, {
1413
- maxAge: PLATFORM_COOKIE_DURATION,
1414
- domain: '*',
1415
- });
1406
+ let setPlatformCookie = false;
1407
+ if (!this.isMobileApp()) {
1408
+ // don't change platform in mobile apps from query or cookie
1409
+ const platform = this.ctx.query[PLATFORM_PARAM] || this.cookie(PLATFORM_COOKIE);
1410
+ setPlatformCookie = this.setPlatform(platform);
1411
+ if (setPlatformCookie) {
1412
+ this.cookie(PLATFORM_COOKIE, platform, {
1413
+ maxAge: PLATFORM_COOKIE_DURATION,
1414
+ domain: '*',
1415
+ });
1416
+ }
1417
+ }
1418
+ if (!setPlatformCookie) {
1419
+ const smPlatform = this.header('x-sm-platform');
1420
+ if (smPlatform) {
1421
+ this._platform = smPlatform;
1422
+ }
1416
1423
  }
1417
1424
  }
1418
1425
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smpx/koa-request",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Handle basic tasks for koajs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",