diff --git a/README.md b/README.md index 96da0e9..2febaa6 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ const launch = require('launch-editor') launch( // filename:line:column // both line and column are optional + // `file://` URIs are also supported 'foo.js:12:34', // try specific editor bin first (optional) 'code', diff --git a/packages/launch-editor/index.js b/packages/launch-editor/index.js index f2ccf7f..6e27b1b 100644 --- a/packages/launch-editor/index.js +++ b/packages/launch-editor/index.js @@ -48,6 +48,11 @@ function isTerminalEditor (editor) { const positionRE = /:(\d+)(:(\d+))?$/ function parseFile (file) { + // support `file://` protocol + if (file.startsWith('file://')) { + file = require('url').fileURLToPath(file) + } + const fileName = file.replace(positionRE, '') const match = file.match(positionRE) const lineNumber = match && match[1]