Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"electron-window-state": "^5.0.2",
"entypo": "^2.1.0",
"existy": "^1.0.1",
"file-url": "^3.0.0",
"flush-write-stream": "^2.0.0",
"folder-walker": "^3.2.0",
"format-duration": "^3.0.2",
Expand All @@ -110,7 +109,7 @@
"common-shakeify": "^1.1.2",
"concat-stream": "^2.0.0",
"dependency-check": "^4.1.0",
"electron": "^27.0.1",
"electron": "^28.0.0",
"electron-builder": "^24.4.0",
"electron-renderify": "0.0.2",
"envify": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion renderer/audio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const path = require('path')
const mainState = remote.require('./index.js')
const needle = 'file://' + path.resolve(__dirname, 'needle.mp3')
let startupNode = document.querySelector('#needle')
const fileUrlFromPath = require('file-url')
const fileUrlFromPath = require('../shared/file-url')

needleSound(startupNode, needle, mainState.volume, mainState.muted)

Expand Down
2 changes: 1 addition & 1 deletion renderer/player/elements/player/artwork.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const html = require('choo/html')
const Component = require('nanocomponent')
const fileUrlFromPath = require('file-url')
const fileUrlFromPath = require('../../../shared/file-url')
const path = require('path')
const defaultBG = path.resolve(window.__dirname, 'default-artwork.png')
const compare = require('nanocomponent/compare')
Expand Down
30 changes: 30 additions & 0 deletions renderer/shared/file-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path = require('path')

// Vendored from https://github.com/sindresorhus/file-url/blob/982123e9af861ce26167de7ef40be3ff9cad2be7/index.js#L2
// because inconvient ESM upgrade

function fileUrl (filePath, options = {}) {
if (typeof filePath !== 'string') {
throw new TypeError(`Expected a string, got ${typeof filePath}`)
}

const { resolve = true } = options

let pathName = filePath
if (resolve) {
pathName = path.resolve(filePath)
}

pathName = pathName.replace(/\\/g, '/')

// Windows drive letter must be prefixed with a slash.
if (pathName[0] !== '/') {
pathName = `/${pathName}`
}

// Escape required characters for path components.
// See: https://tools.ietf.org/html/rfc3986#section-3.3
return encodeURI(`file://${pathName}`).replace(/[?#]/g, encodeURIComponent)
}

module.exports = fileUrl