| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/launch-editor-middleware/ |
Upload File : |
const path = require('path')
const launch = require('launch-editor')
module.exports = (specifiedEditor, srcRoot, onErrorCallback) => {
if (typeof specifiedEditor === 'function') {
onErrorCallback = specifiedEditor
specifiedEditor = undefined
}
if (typeof srcRoot === 'function') {
onErrorCallback = srcRoot
srcRoot = undefined
}
srcRoot = srcRoot || process.cwd()
return function launchEditorMiddleware(req, res) {
let url
try {
const fullUrl = req.url.startsWith('http') ? req.url : `http://localhost${req.url}`
url = new URL(fullUrl)
// eslint-disable-next-line no-unused-vars
} catch (_err) {
res.statusCode = 500
res.end(`launch-editor-middleware: invalid URL.`)
return
}
const file = url.searchParams.get('file')
if (!file) {
res.statusCode = 500
res.end(
`launch-editor-middleware: required query param "file" is missing.`
)
} else {
const resolved = file.startsWith('file://') ? file : path.resolve(srcRoot, file)
launch(resolved, specifiedEditor, onErrorCallback)
res.end()
}
}
}