Skip to content

Commit 1d1a24a

Browse files
jpstevensjhnns
authored andcommitted
fix: Fix thrown error with input that only contains whitespaces
Fix issues #32, #61
1 parent 601d192 commit 1d1a24a

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/parseDomain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function parseDomain(url, options) {
5656
let urlSplit;
5757
let domain;
5858

59-
if (normalizedUrl === null) {
59+
if (!normalizedUrl) {
6060
return null;
6161
}
6262

test/parseDomain.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ describe("parseDomain(url)", () => {
142142
expect(parseDomain(undefined)).to.equal(null);
143143
expect(parseDomain({})).to.equal(null);
144144
expect(parseDomain("")).to.equal(null);
145+
expect(parseDomain(" ")).to.equal(null);
146+
expect(parseDomain("\xa0")).to.equal(null);
145147
});
146148

147149
it("should work with domains that could match multiple tlds", () => {

0 commit comments

Comments
 (0)