Skip to content

Commit

Permalink
Fix undefined protocolVersion error #45
Browse files Browse the repository at this point in the history
  • Loading branch information
jannispinter committed Jun 10, 2020
1 parent 759f857 commit 5b016b6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ async function updateIcon(tabId, protocolVersion, warning) {
}

async function loadSavedSecurityInfoAndUpdateIcon(details) {
cached_version = tabMainProtocolMap.get(details.tabId).protocolVersion;
securityInfo = tabMainProtocolMap.get(details.tabId);
cached_version = securityInfo !== "undefined" ? securityInfo.protocolVersion : undefined;

This comment has been minimized.

Copy link
@johnp

johnp Jun 12, 2020

@jannispinter

this should probably be:

cached_version = typeof securityInfo !== "undefined" ? securityInfo.protocolVersion : undefined;

(missing typeof; as it is, this doesn't fix #45).

This comment has been minimized.

Copy link
@ashucg

ashucg Jul 13, 2020

Contributor

@johnp you are right, we need to use typeof because we are comparing it with a string value.

Or we can write it as:

cached_version = securityInfo ? securityInfo.protocolVersion : undefined;

I have worked on a possible fix for #44 and used the second method in my code. I have just pushed my code.

if (typeof cached_version !== "undefined" && cached_version !== "unknown") {
if (tabMainDowngradedMap.has(details.tabId)) {
await updateIcon(details.tabId, cached_version, tabMainDowngradedMap.get(details.tabId));
Expand Down

0 comments on commit 5b016b6

Please sign in to comment.