747c11c917
Improves proxy support - Automatically detect and dehyphenise https proxies which use EZProxy HttpsHyphens - Web translators now pass around Zotero.Proxy instances which can proxify/deproxify urls passed to `translate.setLocation()` before calling `translate.getTranslators()`/ translate.detect()`. The proxy passing is done within connector background/injected processes and between standalone and connectors. - Proxy protocol unified with connectors. Connectors can now pass proxies to `/connector/save_items`. The proxies will be used to resolve true item and attachment urls when saving. Closes zotero/zotero#578, zotero/zotero#721 Relevant zotero/zotero#34, zotero/zotero#556
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
describe("Zotero.Proxies", function(){
|
|
describe("#getPotentialProxies", function() {
|
|
it("should return the provided url mapped to null when url is not proxied", function() {
|
|
let url = "http://www.example.com";
|
|
let proxies = Zotero.Proxies.getPotentialProxies(url);
|
|
let expectedProxies = {};
|
|
expectedProxies[url] = null;
|
|
assert.deepEqual(proxies, expectedProxies);
|
|
});
|
|
|
|
it("should return the provided url and deproxied url", function() {
|
|
let url = "https://www.example.com.proxy.example.com";
|
|
let proxies = Zotero.Proxies.getPotentialProxies(url);
|
|
let expectedProxies = {};
|
|
expectedProxies[url] = null;
|
|
expectedProxies["https://www.example.com"] = {scheme: "https://%h.proxy.example.com/%p", dotsToHyphens: false};
|
|
assert.deepEqual(proxies, expectedProxies);
|
|
});
|
|
|
|
it("should return the provided url and deproxied url with replaced hyphens", function() {
|
|
let url = "https://www-example-com.proxy.example.com";
|
|
let proxies = Zotero.Proxies.getPotentialProxies(url);
|
|
let expectedProxies = {};
|
|
expectedProxies[url] = null;
|
|
expectedProxies["https://www.example.com"] = {scheme: "https://%h.proxy.example.com/%p", dotsToHyphens: true};
|
|
assert.deepEqual(proxies, expectedProxies);
|
|
});
|
|
});
|
|
});
|