commit 4ad2a4f5bf14501e69655d1d96b623e4fe059e8f
parent e59bb3078f62fb26cc5cbafd4e47857f467fa3c4
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 16 Jun 2009 06:52:17 +0000
Fix broken documents after syncing for the first time with 2.0b5
Diffstat:
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/uri.js b/chrome/content/zotero/xpcom/uri.js
@@ -2,6 +2,26 @@ Zotero.URI = new function () {
var _baseURI = ZOTERO_CONFIG.BASE_URI;
+ /**
+ * Get a URI with the user's local key, if there is one
+ *
+ * @return {String|False} e.g., 'http://zotero.org/users/v3aG8nQf'
+ */
+ this.getLocalUserURI = function () {
+ var key = Zotero.getLocalUserKey();
+ if (!key) {
+ return false;
+ }
+
+ return _baseURI + "users/local/" + Zotero.getLocalUserKey();
+ }
+
+
+ /**
+ * Get a URI for the user, creating a local user key if necessary
+ *
+ * @return {String}
+ */
this.getCurrentUserURI = function () {
var userID = Zotero.userID;
if (userID) {
@@ -78,11 +98,14 @@ Zotero.URI = new function () {
// If this is a local URI, compare to the local user key
if (itemURI.match(/\/users\/local\//)) {
- var currentUserURI = this.getCurrentUserURI() + "/";
- if (itemURI.indexOf(currentUserURI) == 0) {
- itemURI = itemURI.substr(currentUserURI.length);
- var libraryType = 'user';
- var libraryTypeID = null;
+ var localUserURI = this.getLocalUserURI();
+ if (localUserURI) {
+ localUserURI += "/";
+ if (itemURI.indexOf(localUserURI) == 0) {
+ itemURI = itemURI.substr(localUserURI.length);
+ var libraryType = 'user';
+ var libraryTypeID = null;
+ }
}
}