Skip to content

Commit

Permalink
Properly handle requests with malformed URIs (#442)
Browse files Browse the repository at this point in the history
* Properly handle requests with malformed URIs

* Fix tests
  • Loading branch information
leo authored Jul 3, 2018
1 parent 058f054 commit 95d6dc4
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 182 deletions.
14 changes: 7 additions & 7 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const pkg = require('../package');
const readFile = promisify(fs.readFile);
const lookup = promisify(dns.lookup);

const warning = message => chalk`{yellow WARNING:} ${message}`;
const info = message => chalk`{magenta INFO:} ${message}`;
const error = message => chalk`{red ERROR:} ${message}`;
const warning = (message) => chalk`{yellow WARNING:} ${message}`;
const info = (message) => chalk`{magenta INFO:} ${message}`;
const error = (message) => chalk`{red ERROR:} ${message}`;

const updateCheck = async isDebugging => {
const updateCheck = async (isDebugging) => {
let update = null;

try {
Expand Down Expand Up @@ -103,7 +103,7 @@ const getHelp = () => chalk`
{bold $} {cyan serve} -l pipe:\\\\.\\pipe\\{underline PipeName}
`;

const parseEndpoint = str => {
const parseEndpoint = (str) => {
if (!isNaN(str)) {
return [str];
}
Expand Down Expand Up @@ -137,7 +137,7 @@ const parseEndpoint = str => {
}
};

const registerShutdown = fn => {
const registerShutdown = (fn) => {
let run = false;

const wrapper = () => {
Expand All @@ -157,7 +157,7 @@ const startEndpoint = (endpoint, config, args) => {
const {isTTY} = process.stdout;
const clipboard = args['--no-clipboard'] !== true;

server.on('error', err => {
server.on('error', (err) => {
console.error(error(`Failed to serve: ${err.stack}`));
process.exit(1);
});
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"author": "leo",
"license": "MIT",
"devDependencies": {
"@zeit/eslint-config-node": "0.2.13",
"@zeit/eslint-config-node": "0.3.0",
"@zeit/git-hooks": "0.1.4",
"eslint": "4.19.1"
"eslint": "5.0.1"
},
"eslintConfig": {
"extends": [
Expand All @@ -36,13 +36,13 @@
"pre-commit": "lint-staged"
},
"dependencies": {
"@zeit/schemas": "1.2.0",
"ajv": "6.5.1",
"@zeit/schemas": "1.5.1",
"ajv": "6.5.2",
"arg": "2.0.0",
"boxen": "1.3.0",
"chalk": "2.4.1",
"clipboardy": "1.2.3",
"serve-handler": "3.2.1",
"serve-handler": "3.2.3",
"update-check": "1.5.2"
}
}
Loading

0 comments on commit 95d6dc4

Please sign in to comment.