UNPKG

601 BJavaScriptView Raw
1/**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7'use strict';
8
9const launchEditor = require('./launchEditor');
10const launchEditorEndpoint = require('./launchEditorEndpoint');
11
12module.exports = function createLaunchEditorMiddleware() {
13 return function launchEditorMiddleware(req, res, next) {
14 if (req.url.startsWith(launchEditorEndpoint)) {
15 launchEditor(req.query.fileName, req.query.lineNumber);
16 res.end();
17 } else {
18 next();
19 }
20 };
21};