recommend url.format for file URLs

This commit is contained in:
Zeke Sikelianos 2016-08-19 13:31:57 -07:00
parent d9901e62b6
commit 1985432e8e

View file

@ -953,6 +953,20 @@ Same as `webContents.loadURL(url[, options])`.
The `url` can be a remote address (e.g. `http://`) or a path to a local The `url` can be a remote address (e.g. `http://`) or a path to a local
HTML file using the `file://` protocol. HTML file using the `file://` protocol.
To ensure that file URLs are properly formatted, it is recommended to use
Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject)
method:
```javascript
let url = require('url').format({
protocol: 'file',
slashes: true,
pathname: path.join(__dirname, 'index.html')
})
win.loadURL(url)
```
#### `win.reload()` #### `win.reload()`
Same as `webContents.reload`. Same as `webContents.reload`.