-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PS-1123] Improve hostname and domain retrieval #3168
Conversation
…improve-hostname-and-domain-retrieval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a straight improvement. One question before approving, though
@@ -1,7 +0,0 @@ | |||
export function getDomain(host: string): string | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this no longer required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say why this was initially introduced, but with this in place on web and desktop it would actually always return the hostname instead of the domain.
I just tested this with the 2fa reports on web and it actually produces more hits with my changes. As this now grabs the domain and checks it against the list from 2fa.directory. A hostname would not match with an entry.
…prove-hostname-and-domain-retrieval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'm going to tag this with needs-qa
, but it seems like an amorphous "please test autofill" to me, do you have any better qa notes than that?
@MGibson1 Thanks for the review, I'll add some more detailed notes for QA on the ticket. |
…prove-hostname-and-domain-retrieval
…prove-hostname-and-domain-retrieval
…prove-hostname-and-domain-retrieval
Received approval from QA, just need a quick review of the 3 last merge commits pulling in master, before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, love the tests. I would love to have a test defining the behavior of a file protocol (i.e file:///C:/something/form.pdf
) going through getDomain
and getHostname
I'd imagine it would be null but mostly just want to define our expectation with something like that.
expect(Utils.getDomain("https://my_vault.bitwarden.com/")).toBe("bitwarden.com"); | ||
}); | ||
|
||
it("should support urls containing umlauts", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL what that is called.
…prove-hostname-and-domain-retrieval
Good catch with the file-schema links. I had to add some exceptions to getHostname as they were returning |
Type of change
Objective
Finally got around finishing up bitwarden/jslib#547
Improve the retrieval and validation of hostnames and domains, which affects url matching/auto-fill
The main change is replacing
tldjs
with tldtsNewly supported scenarios:
Utils.tldEndingRegex
)Utils.tldEndingRegex
).Asana task: https://app.asana.com/0/1153292148278596/1201431275009049/f
Could possibly improve or fix the following issues:
Code changes
Improving hostname and domain detection/validation
Uninstall
tldjs
and installtldts
as replacementnpm i
libs/common/spec/misc/utils.spec.ts: Added unit tests for
Utils.getDomain
andUtils.getHostname
libs/common/src/misc/utils.ts:
tldjs
withtldts
tldEndingRegex
about:
protocolUtils.getUrl
internally but relies ontldts.getHostname
libs/common/src/misc/tldjs.noop.ts: Deleted tldjs.noop implementation
apps/desktop/tsconfig.json: Removed usage of tldjs.noop
apps/web/tsconfig.json: Removed usage of tldjs.noop
isWebsite/launch detection
isWebsite
,launchUri
,canLaunch
) ofloginUriView
Utils.tldEndingRegex
with improvedUtils.getDomain
Fix accessibility-cookie
tldjs.noop
-impl which previously always returned a hostname instead of the domain when callingtldjs.getDomain()
, the call toUtils.getDomain
needed to get changed toUtils.getHostName()
.Before you submit