Skip to content

Commit 824b401

Browse files
authored
Merge pull request #500 from salesforce/499_domain_match_fix
Fix regression bug in `domainMatch`
2 parents 9328fc4 + a312820 commit 824b401

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/__tests__/domainMatch.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ describe('domainMatch', () => {
7474
['🫠.com', 'xn--129h.com', true], // Emoji!
7575
['ρһіѕһ.info', 'xn--2xa01ac71bc.info', true], // Greek + Cyrillic characters
7676
['猫.cat', 'xn--z7x.cat', true], // Japanese characters
77+
78+
// domain that needs to be canonicalized
79+
['www.google.com', '.google.com', true],
7780
])('domainMatch(%s, %s) => %s', (string, domain, expectedValue) => {
7881
expect(domainMatch(string, domain)).toBe(expectedValue)
7982
})

lib/cookie/domainMatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function domainMatch(
8484
/* " o All of the following [three] conditions hold:" */
8585

8686
/* "* The domain string is a suffix of the string" */
87-
const idx = _str.lastIndexOf(cookieDomain)
87+
const idx = _str.lastIndexOf(_domStr)
8888
if (idx <= 0) {
8989
return false // it's a non-match (-1) or prefix (0)
9090
}

0 commit comments

Comments
 (0)