From 30817d0b9f64a7c396e9722320198df496f7a8c1 Mon Sep 17 00:00:00 2001 From: xuchaoying Date: Mon, 2 Sep 2019 10:22:49 +0800 Subject: [PATCH 1/2] build(npm-lock): rename package-lock to npm-shrinkwrap --- package-lock.json => npm-shrinkwrap.json | 0 packages/svrx-util/{package-lock.json => npm-shrinkwrap.json} | 0 packages/svrx/{package-lock.json => npm-shrinkwrap.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename package-lock.json => npm-shrinkwrap.json (100%) rename packages/svrx-util/{package-lock.json => npm-shrinkwrap.json} (100%) rename packages/svrx/{package-lock.json => npm-shrinkwrap.json} (100%) diff --git a/package-lock.json b/npm-shrinkwrap.json similarity index 100% rename from package-lock.json rename to npm-shrinkwrap.json diff --git a/packages/svrx-util/package-lock.json b/packages/svrx-util/npm-shrinkwrap.json similarity index 100% rename from packages/svrx-util/package-lock.json rename to packages/svrx-util/npm-shrinkwrap.json diff --git a/packages/svrx/package-lock.json b/packages/svrx/npm-shrinkwrap.json similarity index 100% rename from packages/svrx/package-lock.json rename to packages/svrx/npm-shrinkwrap.json From 49e775b078fc47b4b87a7ffde2e590fbae6ddfd5 Mon Sep 17 00:00:00 2001 From: xuchaoying Date: Mon, 2 Sep 2019 11:58:40 +0800 Subject: [PATCH 2/2] fix(config): fix number check for option value --- packages/svrx/__tests__/spec/svrx.configure.js | 10 ++++++++++ packages/svrx/lib/configure/index.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/svrx/__tests__/spec/svrx.configure.js b/packages/svrx/__tests__/spec/svrx.configure.js index 5481f9b9..cd486753 100644 --- a/packages/svrx/__tests__/spec/svrx.configure.js +++ b/packages/svrx/__tests__/spec/svrx.configure.js @@ -244,6 +244,16 @@ describe('CLI Config', () => { expect(plugin.get('foo')).to.eql(''); expect(plugin.get('bar')).to.eql('foo'); }); + + it('should parse web url with number correctly', () => { + const server = createServer({}, { + plugin: [ + 'test?host=https://test.163.com', + ], + }); + const plugin = server.config.getPlugin('test'); + expect(plugin.get('host')).to.eql('https://test.163.com'); + }); }); describe('add plugin with shortcut', () => { diff --git a/packages/svrx/lib/configure/index.js b/packages/svrx/lib/configure/index.js index 07a5115c..1fd24f69 100644 --- a/packages/svrx/lib/configure/index.js +++ b/packages/svrx/lib/configure/index.js @@ -204,7 +204,7 @@ class Configure { }; Object.keys(ops).forEach((key) => { const value = ops[key]; - if (/\d+/.test(value)) { + if (/^\d+$/.test(value)) { newOps[key] = parseInt(value, 10); } else if (value in keyMap) { newOps[key] = keyMap[value];