Skip to content

Commit

Permalink
fix(config): fix number check for option value (#77)
Browse files Browse the repository at this point in the history
* build(npm-lock): rename package-lock to npm-shrinkwrap

* fix(config): fix number check for option value
  • Loading branch information
xuchaoying authored Sep 2, 2019
1 parent c012bbd commit d82a13c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/svrx/__tests__/spec/svrx.configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/svrx/lib/configure/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit d82a13c

Please sign in to comment.