Add files via upload

This commit is contained in:
erosman 2023-11-20 15:35:53 +03:30 committed by GitHub
parent 26e41c1bfc
commit bf4e42f808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 8 deletions

View File

@ -132,7 +132,7 @@ export class Migrate {
};
// Validate RegExp, deactivate on error
!Pattern.validate(p.pattern, p.type) && (p.active = false);
!Pattern.validate(pat.pattern, pat.type) && (pat.active = false);
// whitelist: Inclusive/Exclusive
p.whitelist === 'Inclusive' ? pxy.include.push(pat) : pxy.exclude.push(pat);

View File

@ -89,6 +89,7 @@ class Options {
const arr = passthrough.split(/[\s,;]+/)
.map(i => /[\d.]+\/\d+/.test(i) ? i : i.replace(/(?<=[a-z\d])\/[^\s,;]*/gi, ''));// remove path
this.passthrough.value = [...new Set(arr)].join(separator); // remove duplicates
pref.passthrough = this.passthrough.value;
// --- check and build proxies & patterns
const data = [];
@ -511,13 +512,13 @@ class Proxies {
});
pac.addEventListener('change', e => {
const {hostname, port} = App.parseURL(e.target.value);
if (!hostname) {
const {hostname: h, port: p} = App.parseURL(e.target.value);
if (!h) {
e.target.classList.add('invalid');
return;
}
hostname.value = hostname;
port && (port.value = port);
hostname.value = h;
p && (port.value = p);
});
// patterns
@ -944,6 +945,21 @@ class ImportProxyList {
pram[key.toLowerCase()] = value;
}
// fix missing default port
if (!pram.port) {
switch (type) {
case 'http':
case 'ws':
pram.port = '80';
break;
case 'https':
case 'wss':
pram.port = '443';
break;
}
}
// proxy template
const pxy = {
active: pram.active !== 'false', // defaults to true

View File

@ -64,7 +64,7 @@ export class Proxy {
if (!control) {
browser.action.setTitle({title: browser.i18n.getMessage('controlledByOtherExtensions')});
browser.action.setBadgeText({text: ''});
browser.action.setBadgeText({text: ''});
return null;
}
@ -284,7 +284,7 @@ String.raw`function FindProxyForURL(url, host) {
// Chrome commands returns command, tab
static async excludeHost(pref, tab) {
const activeTab = tab || await this.getActiveTab();
const activeTab = tab ? [tab] : await this.getActiveTab();
const url = this.getURL(activeTab[0].url);
if (!url) { return; }
@ -302,7 +302,7 @@ String.raw`function FindProxyForURL(url, host) {
this.set(pref); // update Proxy
}
static async getActiveTab() {
static getActiveTab() {
return browser.tabs.query({currentWindow: true, active: true});
}