Merge pull request #102 from electron/url-format
Format URL passed to BrowserWindow.loadURL
This commit is contained in:
commit
3d18c59748
|
@ -23,8 +23,10 @@ To clone and run this repository you'll need [Git](https://git-scm.com) and [Nod
|
||||||
git clone https://github.com/electron/electron-quick-start
|
git clone https://github.com/electron/electron-quick-start
|
||||||
# Go into the repository
|
# Go into the repository
|
||||||
cd electron-quick-start
|
cd electron-quick-start
|
||||||
# Install dependencies and run the app
|
# Install dependencies
|
||||||
npm install && npm start
|
npm install
|
||||||
|
# Run the app
|
||||||
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/latest).
|
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/latest).
|
||||||
|
|
9
main.js
9
main.js
|
@ -4,6 +4,9 @@ const app = electron.app
|
||||||
// Module to create native browser window.
|
// Module to create native browser window.
|
||||||
const BrowserWindow = electron.BrowserWindow
|
const BrowserWindow = electron.BrowserWindow
|
||||||
|
|
||||||
|
const path = require('path')
|
||||||
|
const url = require('url')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
@ -13,7 +16,11 @@ function createWindow () {
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600})
|
mainWindow = new BrowserWindow({width: 800, height: 600})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadURL(`file://${__dirname}/index.html`)
|
mainWindow.loadURL(url.format({
|
||||||
|
pathname: path.join(__dirname, 'index.html'),
|
||||||
|
protocol: 'file:',
|
||||||
|
slashes: true
|
||||||
|
}))
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
mainWindow.webContents.openDevTools()
|
mainWindow.webContents.openDevTools()
|
||||||
|
|
Loading…
Reference in New Issue