Skip to content

Commit 7289809

Browse files
Fix semver compare on source builds (#310)
* Fix semver compare on source builds * Clarify semver comments * Reclarify semver comments * Fix semver compare
1 parent f7bd475 commit 7289809

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: src/dialogs/editor/index.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createRoot } from "react-dom/client";
55
import Citation from "../../cita/citation";
66
import Wikicite from "../../cita/wikicite";
77
import { compareSemVer } from "semver-parser";
8-
import ZoteroOverlay from "../../cita/zoteroOverlay";
98
import WikiciteChrome from "../../cita/wikiciteChrome";
109
import PID from "../../cita/PID";
1110

@@ -119,9 +118,19 @@ window.addEventListener("load", () => {
119118
const itemBoxLabel = document.createElement("h4");
120119
itemBoxLabel.textContent = "Target"; //Wikicite.getString("wikicite.editor.title");
121120
container.appendChild(itemBoxLabel);
122-
// "item-box" was renamed to "info-box" in Zotero 7.0.10. We compare to 7.0.9 to include the beta versions.
123-
const tagName =
124-
compareSemVer(Zotero.version, "7.0.9") === 1 ? "info-box" : "item-box";
121+
// "item-box" was renamed to "info-box" in Zotero 7.0.10, so check if we have at least this version of Zotero.
122+
let semVerCompare: number;
123+
try {
124+
semVerCompare = compareSemVer(Zotero.version, "7.0.10");
125+
} catch (e) {
126+
// Zotero.version is not a valid semver string
127+
// This may happen when installing certain beta versions or building Zotero from source, so we treat it as if it is at least Zotero 7.0.10
128+
Zotero.log(
129+
`Zotero version (${Zotero.version}) is not a valid semver string - maybe you installed a beta version or built it from source? Treating this version of Zotero as at least 7.0.10.`,
130+
);
131+
semVerCompare = 1;
132+
}
133+
const tagName = semVerCompare >= 0 ? "info-box" : "item-box";
125134
const itemBox = document.createElementNS(
126135
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
127136
tagName,

Diff for: translators/zotkat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit ece06e457def61ab749d27c2d9be51b07d72d25a

0 commit comments

Comments
 (0)