0

Hello I am doing this electron project and I came across this issue where when I give this path

`file://${path.join(__dirname, `../build/index.html#/view/${arg}`)}`

I was hoping for this,

file:///C:/Users/admin/AppData/Local/Programs/electrondesktop/resources/app.asar/build/index.html#/view/61995a6fcf31f7cddedcce59

Instead, I get,

file:///C:/Users/admin/AppData/Local/Programs/electrondesktop/resources/app.asar/build/index.html#\view\61995a6fcf31f7cddedcce59

Notice how the forward-slash("/") changes to back-slash("\") after the hash(#) symbol

index.html#/view/61995a6fcf31f7cddedcce59

index.html#\view\61995a6fcf31f7cddedcce59

How do I fix this?

I'm using electron with react btw.

1 Answers1

0

Figured out the Answer!

Apparently, there is another way to avoid slashes after #

Its something like this,

url.format({
         pathname: path.join(__dirname,`index.html`),
         protocol:'file',
         slashes:true,
         hash:`#/view/61995a6fcf31f7cddedcce59`
       })

__dirname gives the path I needed. i.e. file:///C:/Users/admin/AppData/Local/Programs/electrondesktop/resources/app.asar/build/