Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
extension icons should appear (macOS)
Browse files Browse the repository at this point in the history
changes file:// to chrome://brave

Issue #11142

Auditors:
@bridiver @diracdeltas @darkdh @jonathansampson

fix whitespace

add unit test
  • Loading branch information
kevinlawler authored and bsclifton committed Dec 22, 2017
1 parent 4028c66 commit a51b7ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const contextMenus = require('./browser/extensions/contextMenus')
const extensionActions = require('./common/actions/extensionActions')
const config = require('../js/constants/config')
const appConfig = require('../js/constants/appConfig')
const {fileUrl} = require('../js/lib/appUrlUtil')
const {chromeUrl} = require('../js/lib/appUrlUtil')
const {getExtensionsPath, getBraveExtUrl, getBraveExtIndexHTML} = require('../js/lib/appUrlUtil')
const {getSetting} = require('../js/settings')
const settings = require('../js/constants/settings')
Expand Down Expand Up @@ -407,7 +407,9 @@ module.exports.init = () => {
extensionInfo.setState(installInfo.id, extensionStates.ENABLED)
extensionInfo.setInstallInfo(installInfo.id, installInfo)
installInfo.filePath = installInfo.base_path
installInfo.base_path = fileUrl(installInfo.base_path)

installInfo.base_path = chromeUrl(installInfo.base_path)

extensionActions.extensionInstalled(installInfo.id, installInfo)
extensionActions.extensionEnabled(installInfo.id)
})
Expand Down
7 changes: 7 additions & 0 deletions js/lib/appUrlUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ module.exports.fileUrl = (filePath) => {
return encodeURI('file://' + fileUrlPath)
}

module.exports.chromeUrl = (filePath = '') => {
filePath = module.exports.fileUrl(filePath)
filePath = filePath.replace('file://', 'chrome://brave')

return filePath
}

/**
* Gets the URL of a page hosted by the braveExtension or torrentExtension
* Returns 'chrome-extension://<...>'
Expand Down
8 changes: 8 additions & 0 deletions test/unit/lib/appUrlUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ describe('appUrlUtil test', function () {
assert.equal(fileUrl, expected)
})
})
describe('chromeUrl', function () {
it('can convert file paths', function () {
const filePath = '/users/bbondy/space here/tesT.html'
const chromeUrl = appUrlUtil.chromeUrl(filePath)
const expected = 'chrome://brave/users/bbondy/space%20here/tesT.html'
assert.equal(chromeUrl, expected)
})
})
describe('newFrameUrl', function () {
describe('when NEWTAB_MODE = HOMEPAGE', function () {
it('returns the configured home page', function () {
Expand Down

0 comments on commit a51b7ea

Please sign in to comment.