Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #16557 from crdlc/bug-975834
Browse files Browse the repository at this point in the history
Bug 975834 - homescreen bookmarks do not work for URLs ending in a file
  • Loading branch information
Cristian Rodriguez committed Feb 27, 2014
2 parents 07883f3 + f4c1a2d commit d7ceb7d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
5 changes: 2 additions & 3 deletions apps/homescreen/everything.me/js/etmmanager.js
Expand Up @@ -323,9 +323,8 @@ var EvmeManager = (function EvmeManager() {
removeGridItem: removeGridItem,

isBookmarked: function isBookmarked(url) {
// Bookmarks have a trailing '/' in order to distinguish from apps
// internally in the Homescreen
return GridManager.getApp(url.endsWith('/') ? url : url + '/');
return GridManager.getIconForBookmark(
Bookmark.prototype.generateIndex(url));
},

getIconByDescriptor: getIconByDescriptor,
Expand Down
11 changes: 8 additions & 3 deletions apps/homescreen/js/bookmark.js
Expand Up @@ -3,15 +3,20 @@
var Bookmark = function Bookmark(params) {
GridItem.call(this, params);

var url = params.bookmarkURL.trim();
this.url = this.origin = this.bookmarkURL = url.endsWith('/') ? url :
url + '/';
this.url = this.origin = params.bookmarkURL.trim();
// The bookmarkURL is used for indexing bookmarks in the homescreen. "It's not
// a real URL", just used for indexing in homescreen (bug #976955)
this.bookmarkURL = this.generateIndex(this.url);
this.type = GridItemsFactory.TYPE.BOOKMARK;
};

Bookmark.prototype = {
__proto__: GridItem.prototype,

generateIndex: function bookmark_generateIndex(url) {
return 'bookmark:' + url;
},

launch: function bookmark_launch() {
var features = this.getFeatures();

Expand Down
2 changes: 1 addition & 1 deletion apps/homescreen/test/unit/bookmark_editor_test.js
Expand Up @@ -87,7 +87,7 @@ suite('bookmark.js >', function() {
test('This bookmark defines the url correctly >', function() {
assert.equal(bookmark.origin, URL);
assert.equal(bookmark.url, URL);
assert.equal(bookmark.bookmarkURL, URL);
assert.equal(bookmark.bookmarkURL, bookmark.generateIndex(URL));
});

test('This bookmark defines the icon correctly >', function() {
Expand Down
19 changes: 3 additions & 16 deletions apps/homescreen/test/unit/bookmark_test.js
Expand Up @@ -40,22 +40,9 @@ suite('bookmark.js >', function() {
});

test('This bookmark defines the url correctly >', function() {
var expectedURL = URL + '/';
assert.equal(bookmark.origin, expectedURL);
assert.equal(bookmark.url, expectedURL);
assert.equal(bookmark.bookmarkURL, expectedURL);

bookmark = new Bookmark({
bookmarkURL: URL + '/',
name: name,
icon: icon,
iconable: false,
useAsyncPanZoom: true
});

assert.equal(bookmark.origin, expectedURL);
assert.equal(bookmark.url, expectedURL);
assert.equal(bookmark.bookmarkURL, expectedURL);
assert.equal(bookmark.origin, URL);
assert.equal(bookmark.url, URL);
assert.equal(bookmark.bookmarkURL, bookmark.generateIndex(URL));
});

test('This bookmark defines the icon correctly >', function() {
Expand Down

0 comments on commit d7ceb7d

Please sign in to comment.