diff --git a/chrome/content/zotero/xpcom/recognizePDF.js b/chrome/content/zotero/xpcom/recognizePDF.js index a7fd400780..d9de4a9f47 100644 --- a/chrome/content/zotero/xpcom/recognizePDF.js +++ b/chrome/content/zotero/xpcom/recognizePDF.js @@ -226,10 +226,10 @@ Zotero.RecognizePDF = new function () { var metadata = item.toJSON(); var data = { description, version, json, metadata }; - var uri = ZOTERO_CONFIG.RECOGNIZE_URL + 'report'; + var url = _getBaseURL() + 'report'; return Zotero.HTTP.request( "POST", - uri, + url, { successCodes: [200, 204], headers: { @@ -386,18 +386,8 @@ Zotero.RecognizePDF = new function () { } async function _query(json) { - // TODO: Use main API URL for recognizer server - //let uri = Zotero.Prefs.get("api.url") || ZOTERO_CONFIG.API_URL; - let uri = Zotero.Prefs.get("api.url") || ZOTERO_CONFIG.RECOGNIZE_URL; - - if (!uri.endsWith('/')) { - uri += '/'; - } - - uri += 'recognize'; - + var uri = _getBaseURL() + 'recognize'; let client = Zotero.Sync.Runner.getAPIClient(); - let req = await client.makeRequest( 'POST', uri, @@ -410,7 +400,6 @@ Zotero.RecognizePDF = new function () { noAPIKey: true } ); - return JSON.parse(req.responseText); } @@ -581,5 +570,24 @@ Zotero.RecognizePDF = new function () { return null; } + + /** + * To customize the recognizer endpoint, set either recognize.url (used directly) + * or services.url (used with a 'recognizer/' suffix). + */ + function _getBaseURL() { + var url = Zotero.Prefs.get("recognize.url"); + if (url) { + if (!url.endsWith('/')) { + url += '/'; + } + return url; + } + url = Zotero.Prefs.get("services.url") || ZOTERO_CONFIG.SERVICES_URL; + if (!url.endsWith('/')) { + url += '/'; + } + return url + "recognizer/"; + } }; diff --git a/resource/config.js b/resource/config.js index 6af850634b..37b40c394d 100644 --- a/resource/config.js +++ b/resource/config.js @@ -11,7 +11,6 @@ var ZOTERO_CONFIG = { PROXY_AUTH_URL: 'https://zoteroproxycheck.s3.amazonaws.com/test', API_URL: 'https://api.zotero.org/', STREAMING_URL: 'wss://stream.zotero.org/', - RECOGNIZE_URL: 'https://recognize.zotero.org/', SERVICES_URL: 'https://services.zotero.org/', API_VERSION: 3, CONNECTOR_MIN_VERSION: '5.0.39', // show upgrade prompt for requests from below this version