isaacs/st — pull request #32 by joeybaker (2014-02-04 00:15:56+00:00)
Title: Malformed URLs no longer cause a crash

We're running `st` in production and had a bot hit our server with a bunch of bad URLs that caused st to crash. Here's the stack trace:

```json
"stack": [
"URIError: URI malformed",
" at decodeURIComponent (native)",
" at Mount.getPath (/opt/app/node_modules/st/st.js:162:7)",
" at Mount.serve (/opt/app/node_modules/st/st.js:190:16)",
" at dispatch (/opt/app/node_modules/union/lib/routing-stream.js:110:21)",
" at RoutingStream.route (/opt/app/node_modules/union/lib/routing-stream.js:121:5)",
" at g (events.js:180:16)",
" at EventEmitter.emit (events.js:117:20)",
" at IncomingMessage.Readable.pipe (_stream_readable.js:548:8)",
" at Server.requestHandler (/opt/app/node_modules/union/lib/core.js:50:9)",
" at Server.EventEmitter.emit (events.js:98:17)"
]
```

The problem appears to be that a malformed URL causes an uncaught exception when `decodeURIComponent` fails. This solves the problem simply with a try/catch.