diff --git a/toolkit/components/places/Bookmarks.jsm b/toolkit/components/places/Bookmarks.jsm index fe8bfc6ff6d6..ed5b0eb5ad50 100644 --- a/toolkit/components/places/Bookmarks.jsm +++ b/toolkit/components/places/Bookmarks.jsm @@ -767,7 +767,7 @@ function* updateBookmark(info, item, newParent) { `INSERT OR IGNORE INTO moz_places (url, rev_host, hidden, frecency, guid) VALUES (:url, :rev_host, 0, :frecency, GENERATE_GUID()) `, { url: info.url ? info.url.href : null, - rev_host: getReversedHost(info.url), + rev_host: PlacesUtils.getReversedHost(info.url), frecency: info.url.protocol == "place:" ? 0 : -1 }); tuples.set("url", { value: info.url.href , fragment: "fk = (SELECT id FROM moz_places WHERE url = :url)" }); @@ -858,7 +858,7 @@ function* insertBookmark(item, parent) { yield db.executeCached( `INSERT OR IGNORE INTO moz_places (url, rev_host, hidden, frecency, guid) VALUES (:url, :rev_host, 0, :frecency, GENERATE_GUID()) - `, { url: item.url.href, rev_host: getReversedHost(item.url), + `, { url: item.url.href, rev_host: PlacesUtils.getReversedHost(item.url), frecency: item.url.protocol == "place:" ? 0 : -1 }); } @@ -1088,17 +1088,6 @@ function removeSameValueProperties(dest, src) { */ function toURI(url) NetUtil.newURI(url.href); -/** - * Reverse a host based on the moz_places algorithm, that is reverse the host - * string and add a trialing period. For example "google.com" becomes - * "moc.elgoog.". - * - * @param url - * the URL to generate a rev host for. - * @return the reversed host string. - */ -function getReversedHost(url) url.host.split("").reverse().join("") + "."; - /** * Convert a Date object to a PRTime (microseconds). * diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index 874c40bcb778..1c7eed8be2d8 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -384,6 +384,18 @@ this.PlacesUtils = { return aNode.itemId; }, + /** + * Reverse a host based on the moz_places algorithm, that is reverse the host + * string and add a trailing period. For example "google.com" becomes + * "moc.elgoog.". + * + * @param url + * the URL to generate a rev host for. + * @return the reversed host string. + */ + getReversedHost(url) + url.host.split("").reverse().join("") + ".", + /** * String-wraps a result node according to the rules of the specified * content type.