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

15 lines
479 B
JavaScript
Raw Normal View History

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()
}
}