Socket
Socket
Sign inDemoInstall

parse-domain

Package Overview
Dependencies
0
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

4

package.json
{
"name": "parse-domain",
"version": "0.1.0",
"description": "Finds the sub-domain, domain and top-level-domain from an url",
"version": "0.1.1",
"description": "Splits an url into sub-domain, domain and top-level-domain",
"main": "./lib/parseDomain.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -10,4 +10,4 @@ parse-domain

expect(parseDomain("www.example.co.uk")).to.eql({
subdomain: "www",
expect(parseDomain("some.subdomain.example.co.uk")).to.eql({
subdomain: "some.subdomain",
domain: "example",

@@ -17,8 +17,11 @@ tld: "co.uk"

expect(parseDomain("https://user@www.some.other.subdomain.example.co.uk"
+ ":8080/some/path?and&query#hash")).to.eql({
subdomain: "www.some.other.subdomain",
expect(parseDomain("https://user:password@example.co.uk:8080/some/path?and&query#hash")).to.eql({
subdomain: "",
domain: "example",
tld: "co.uk"
});
expect(parseDomain("unknown.tld.kk")).to.equal(null);
expect(parseDomain("invalid url")).to.equal(null);
expect(parseDomain({})).to.equal(null);
```

@@ -45,4 +48,6 @@

### parseDomain(url: String): ParsedDomain
### parseDomain(url: String): ParsedDomain|null
Returns `null` if `url` has an unknown tld or if it's not a valid url.
### ParsedDomain

@@ -63,2 +68,2 @@

MIT
Unlicense

@@ -82,3 +82,3 @@ "use strict";

it("should work also work with the minimum", function () {
it("should also work with the minimum", function () {
expect(parseDomain("example.com")).to.eql({

@@ -85,0 +85,0 @@ subdomain: "",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc