diff --git a/.travis.yml b/.travis.yml index 960bc57..ce21122 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - '8' - - '9' + - '10' install: - npm i npminstall && npminstall script: diff --git a/LICENSE b/LICENSE index acf7f41..7295685 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2017 Alibaba Group Holding Limited and other contributors. +Copyright (c) 2017-present Alibaba Group Holding Limited and other contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/appveyor.yml b/appveyor.yml index d0aa47e..981e82b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ environment: matrix: - nodejs_version: '8' - - nodejs_version: '9' + - nodejs_version: '10' install: - ps: Install-Product node $env:nodejs_version diff --git a/lib/assets_context.js b/lib/assets_context.js index 404b7c5..ff2d567 100644 --- a/lib/assets_context.js +++ b/lib/assets_context.js @@ -1,13 +1,6 @@ 'use strict'; -const fs = require('fs'); -const path = require('path'); const assert = require('assert'); -const utility = require('utility'); - -const CONTEXT_TEMPLATE_ID = 'context' + utility.sha1(String(Date.now())); -// https://github.com/davidchambers/Base64.js/blob/master/base64.js -const atobScript = fs.readFileSync(path.join(__dirname, 'fixtures/decode.min.js'), 'utf8'); // URL consists of host, resourceBase and entry, // E.X. http://127.0.0.1:7001/public/index.js @@ -50,10 +43,8 @@ class Assets { } getContext(data) { - data = safeStringify(data || this.assetsContext); - let ret = `\n`; - ret += ``; - return ret; + data = safeStringify(data || this.assetsContext || {}); + return ``; } getURL(entry) { @@ -97,7 +88,7 @@ function scriptTpl({ url }) { function safeStringify(data) { if (!data) return ''; - return new Buffer(encodeURIComponent(JSON.stringify(data))).toString('base64'); + return encodeURIComponent(JSON.stringify(data)); } function normalizePublicPath(publicPath) { diff --git a/lib/fixtures/decode.js b/lib/fixtures/decode.js deleted file mode 100644 index 714fdee..0000000 --- a/lib/fixtures/decode.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - -function decode(input) { - return JSON.parse(decodeURIComponent(_atob(input)) || '{}'); -} - -function _atob(input) { - // window.atob - if (typeof window !== 'undefined' && window.atob) return window.atob(input); - if (!input) return ''; - - var str = String(input).replace(/[=]+$/, ''); - if (str.length % 4 == 1) { - throw new Error('atob failed: The string to be decoded is not correctly encoded.'); - } - for ( - var bc = 0, bs, buffer, idx = 0, output = ''; - buffer = str.charAt(idx++); - ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, - bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 - ) { - buffer = chars.indexOf(buffer); - } - return output; -} - -if (typeof module !== 'undefined' && module.exports) module.exports = decode; diff --git a/lib/fixtures/decode.min.js b/lib/fixtures/decode.min.js deleted file mode 100644 index 9252c1a..0000000 --- a/lib/fixtures/decode.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function decode(input){return JSON.parse(decodeURIComponent(_atob(input))||"{}")}function _atob(input){if(typeof window!=="undefined"&&window.atob)return window.atob(input);if(!input)return"";var str=String(input).replace(/[=]+$/,"");if(str.length%4==1){throw new Error("atob failed: The string to be decoded is not correctly encoded.")}for(var bc=0,bs,buffer,idx=0,output="";buffer=str.charAt(idx++);~buffer&&(bs=bc%4?bs*64+buffer:buffer,bc++%4)?output+=String.fromCharCode(255&bs>>(-2*bc&6)):0){buffer=chars.indexOf(buffer)}return output}if(typeof module!=="undefined"&&module.exports)module.exports=decode; \ No newline at end of file diff --git a/package.json b/package.json index c14d150..2e5b5f3 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,8 @@ "app.js" ], "ci": { - "version": "8, 9" + "version": "8, 10", + "license": true }, "repository": { "type": "git", diff --git a/test/assets.test.js b/test/assets.test.js index 63fc9dd..fd591cd 100644 --- a/test/assets.test.js +++ b/test/assets.test.js @@ -5,7 +5,6 @@ const mock = require('egg-mock'); const fs = require('mz/fs'); const assert = require('assert'); - describe('test/assets.test.js', () => { afterEach(mock.restore); @@ -29,9 +28,11 @@ describe('test/assets.test.js', () => { .get('/') .expect(/
<\/div>/) .expect(/<\/link>/) - .expect(/style="display:none">JTdCJTIyZGF0YSUyMiUzQTElN0Q=<\/div>/) .expect(/