electron: shell.showItemInFolder won't open Explorer if forward slashes are present in path

  • Electron version: 1.7.10
  • Operating system: Windows 10, build 1709

If a path contains forward slash(es) on Windows (e.g. C:\some\app/index.html), showItemInFolder will open the containing directory but will not select the file. In Electron 8.x and newer, showItemInFolder will not open an Explorer window at all if forward slashes are present in path.

How to reproduce

https://github.com/YellowAfterlife/abug-electron-showItemInFolder-forward-slashes

const electron = require('electron')
const app = electron.app
const path = require('path')
app.on('ready', () => {
	let test = path.join(__dirname, 'index.html')
	test = test.replace(/^(.+)\\(.+)$/, "$1/$2") // simulate a forward slash in path
	console.log(test)
	console.log(electron.shell.showItemInFolder(test))
	app.quit()
})

From what I’ve seen, no other shell functions show this kind of “partial success” behaviour while returning true.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 22 (4 by maintainers)

Most upvoted comments

It is obviously tempting to just submit a PR with the one-line hack, but also this issue is now old enough to go to school so I’m interested to see how long it will last.

path.normalize

Still here as of v28.0.0-beta.4

Still happens on 4.0.0-beta10 with same code.