Switch to services domain for recognizer requests
The recognizer endpoint can be customized by setting either recognize.url (used directly) or services.url (used with a 'recognizer/' suffix).
This commit is contained in:
parent
4a61cffc99
commit
0ea03ce72c
2 changed files with 22 additions and 15 deletions
|
@ -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/";
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue