Skip to content

Commit a066a5e

Browse files
AkryumGuillaume Chau
authored and
Guillaume Chau
committed
Encode file path as URI + fix console display on Windows
1 parent a79d9c5 commit a066a5e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/devtools/views/components/ComponentInspector.vue

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,29 @@ export default {
9999
},
100100
openInEditor () {
101101
const file = this.target.file
102-
const src = `fetch('/__open-in-editor?file=${file}').then(response => {
103-
if (response.ok) {
104-
console.log('File ${file} opened in editor')
105-
} else {
106-
const msg = 'Opening component ${file} failed'
107-
if (__VUE_DEVTOOLS_TOAST__) {
108-
__VUE_DEVTOOLS_TOAST__(msg, 'error')
102+
// Console display
103+
const fileName = file.replace(/\\/g, '\\\\')
104+
if (file) {
105+
const src = `fetch('/__open-in-editor?file=${encodeURI(file)}').then(response => {
106+
if (response.ok) {
107+
console.log('File ${fileName} opened in editor')
109108
} else {
110-
console.log('%c' + msg, 'color:red')
109+
const msg = 'Opening component ${fileName} failed'
110+
if (__VUE_DEVTOOLS_TOAST__) {
111+
__VUE_DEVTOOLS_TOAST__(msg, 'error')
112+
} else {
113+
console.log('%c' + msg, 'color:red')
114+
}
115+
console.log('Check the setup of your project, see https://github.com/vuejs/vue-devtools/blob/master/docs/open-in-editor.md')
111116
}
112117
console.log('Check the setup of your project, see https://github.com/vuejs/vue-devtools/blob/master/docs/open-in-editor.md')
118+
})`
119+
if (this.$isChrome) {
120+
chrome.devtools.inspectedWindow.eval(src)
121+
} else {
122+
// eslint-disable-next-line no-eval
123+
eval(src)
113124
}
114-
})`
115-
if (this.$isChrome) {
116-
chrome.devtools.inspectedWindow.eval(src)
117-
} else {
118-
// eslint-disable-next-line no-eval
119-
eval(src)
120125
}
121126
}
122127
}
@@ -127,4 +132,3 @@ export default {
127132
.title
128133
white-space nowrap
129134
</style>
130-

0 commit comments

Comments
 (0)