1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/packages/next/server/lib/error-overlay-middleware.js
Tim Neutkens b1c4f3aec4
Monorepo (#5341)
- Implements Lerna
- Moves all source code into `packages/next`
- Keeps integration tests in the root directory
2018-10-01 01:02:10 +02:00

15 lines
479 B
JavaScript

import url from 'url'
import launchEditor from 'launch-editor'
export default function errorOverlayMiddleware (req, res, next) {
if (req.url.startsWith('/_next/development/open-stack-frame-in-editor')) {
const query = url.parse(req.url, true).query
const lineNumber = parseInt(query.lineNumber, 10) || 1
const colNumber = parseInt(query.colNumber, 10) || 1
launchEditor(`${query.fileName}:${lineNumber}:${colNumber}`)
res.end()
} else {
next()
}
}