mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
15 lines
479 B
JavaScript
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()
|
||
|
}
|
||
|
}
|