Skip to content

Commit

Permalink
Fix @ character in path portion
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Feb 7, 2017
1 parent a27a2c8 commit 1f2475e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/parseDomain.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var urlParts = /^(https?:\/\/)?(.+@)?(.+?)(:\d{2,5})?([/?].*)?$/; // 1 = protocol, 2 = auth, 3 = domain, 4 = port, 5 = path
var urlParts = /^(https?:\/\/)?([^/]*@)?(.+?)(:\d{2,5})?([/?].*)?$/; // 1 = protocol, 2 = auth, 3 = domain, 4 = port, 5 = path
var knownTlds = require("./tld.js");
var dot = /\./g;

Expand Down
10 changes: 9 additions & 1 deletion test/parseDomain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ describe("parseDomain(url)", function () {
});
});

it("should allow @ characters in the path", function () {
expect(parseDomain("https://medium.com/@username/")).to.eql({
subdomain: "",
domain: "medium",
tld: "com"
});
});

it("should also work with three-level domains like .co.uk", function () {
expect(parseDomain("www.example.co.uk")).to.eql({
subdomain: "www",
Expand All @@ -87,7 +95,7 @@ describe("parseDomain(url)", function () {
});
});

it("should include private tlds ", function () {
it("should include private tlds", function () {
expect(parseDomain("foo.blogspot.com", { privateTlds: true })).to.eql({
subdomain: "",
domain: "foo",
Expand Down

0 comments on commit 1f2475e

Please sign in to comment.