Assume current domain is valid, even if the TLD is not (#107)
This commit is contained in:
@@ -58,16 +58,22 @@ chrome.runtime.onInstalled.addListener(onExtensionInstalled);
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string path Path to parse
|
||||
* @param string currentHost Current hostname for the active tab
|
||||
* @return string|null Extracted domain
|
||||
*/
|
||||
function pathToDomain(path) {
|
||||
function pathToDomain(path, currentHost) {
|
||||
var parts = path.split(/\//).reverse();
|
||||
for (var key in parts) {
|
||||
if (parts[key].indexOf("@") >= 0) {
|
||||
continue;
|
||||
}
|
||||
var t = TldJS.parse(parts[key]);
|
||||
if (t.isValid && t.tldExists && t.domain !== null) {
|
||||
if (
|
||||
t.isValid &&
|
||||
((t.tldExists && t.domain !== null) ||
|
||||
t.hostname === currentHost ||
|
||||
currentHost.endsWith(`.${t.hostname}`))
|
||||
) {
|
||||
return t.hostname;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +110,7 @@ async function updateMatchingPasswordsCount(tabId) {
|
||||
for (var storeId in response.data.files) {
|
||||
for (var key in response.data.files[storeId]) {
|
||||
const login = response.data.files[storeId][key].replace(/\.gpg$/i, "");
|
||||
const domain = pathToDomain(storeId + "/" + login);
|
||||
const domain = pathToDomain(storeId + "/" + login, currentDomain);
|
||||
const inCurrentDomain =
|
||||
currentDomain === domain || currentDomain.endsWith("." + domain);
|
||||
const recent = settings.recent[sha1(currentDomain + sha1(storeId + sha1(login)))];
|
||||
|
@@ -35,16 +35,22 @@ function handleError(error, type = "error") {
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string path Path to parse
|
||||
* @param string currentHost Current hostname for the active tab
|
||||
* @return string|null Extracted domain
|
||||
*/
|
||||
function pathToDomain(path) {
|
||||
function pathToDomain(path, currentHost) {
|
||||
var parts = path.split(/\//).reverse();
|
||||
for (var key in parts) {
|
||||
if (parts[key].indexOf("@") >= 0) {
|
||||
continue;
|
||||
}
|
||||
var t = TldJS.parse(parts[key]);
|
||||
if (t.isValid && t.tldExists && t.domain !== null) {
|
||||
if (
|
||||
t.isValid &&
|
||||
((t.tldExists && t.domain !== null) ||
|
||||
t.hostname === currentHost ||
|
||||
currentHost.endsWith(`.${t.hostname}`))
|
||||
) {
|
||||
return t.hostname;
|
||||
}
|
||||
}
|
||||
@@ -92,7 +98,7 @@ async function run() {
|
||||
login: response.files[storeId][key].replace(/\.gpg$/i, ""),
|
||||
allowFill: true
|
||||
};
|
||||
login.domain = pathToDomain(storeId + "/" + login.login);
|
||||
login.domain = pathToDomain(storeId + "/" + login.login, settings.host);
|
||||
login.inCurrentDomain =
|
||||
settings.host == login.domain || settings.host.endsWith("." + login.domain);
|
||||
login.recent =
|
||||
|
Reference in New Issue
Block a user