diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 4d8843f4186..42e60eeb125 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -203,7 +203,7 @@ const UrlUtil = { * @returns {Boolean} Whether or not this is a data url. */ isDataUrl: function (url) { - return url.toLowerCase().startsWith('data:') + return typeof url === 'string' && url.toLowerCase().startsWith('data:') }, /** diff --git a/js/state/syncUtil.js b/js/state/syncUtil.js index dda9167b2b9..a478e78391b 100644 --- a/js/state/syncUtil.js +++ b/js/state/syncUtil.js @@ -7,6 +7,7 @@ const Immutable = require('immutable') const writeActions = require('../constants/sync/proto').actions const siteTags = require('../constants/siteTags') const siteUtil = require('./siteUtil') +const {isDataUrl} = require('../lib/urlutil') const CATEGORY_MAP = { bookmark: { @@ -394,7 +395,7 @@ module.exports.createSiteData = (site, appState) => { creationTime: 0 } for (let field in site) { - if (field in siteData) { + if (field in siteData && !isDataUrl(site[field])) { siteData[field] = site[field] } } diff --git a/test/unit/state/syncUtilTest.js b/test/unit/state/syncUtilTest.js index bc24c4159f3..b728eab0d8a 100644 --- a/test/unit/state/syncUtilTest.js +++ b/test/unit/state/syncUtilTest.js @@ -67,6 +67,21 @@ describe('syncUtil', () => { } assert.deepEqual(syncUtil.createSiteData(bookmark), expectedBookmark) }) + + it('bookmark containing data url', () => { + const bookmark = Object.assign({}, site, {tags: ['bookmark'], favicon: 'data:foo'}) + const newValue = Object.assign({}, expectedSite.value, {favicon: ''}) + const expectedBookmark = { + name: 'bookmark', + objectId, + value: { + site: newValue, + isFolder: false, + parentFolderObjectId: undefined + } + } + assert.deepEqual(syncUtil.createSiteData(bookmark), expectedBookmark) + }) }) describe('ipcSafeObject()', () => {