4.3.90 • Published 10 months ago

@taktikorg/veniam-distinctio v4.3.90

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Extract domain name from URL

Donate

This package provides a performant way to extract domain names from URLs without using regular expressions or array manipulations.

Learn more about What is a URL

Supports

  • ESM
  • Node.js
  • Browser

Usage

Installation

$ npm i --save @taktikorg/veniam-distinctio

Development

# Install bun https://bun.sh/
curl -fsSL https://bun.sh/install | bash


# tests
bun test:watch

API

ESM import

import extractDomain from '@taktikorg/veniam-distinctio';

Examples

const urls = [
    'https://www.npmjs.com/package/@taktikorg/veniam-distinctio',
    'http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
    'http://user:password@example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
    'https://npmjs.com/package/@taktikorg/veniam-distinctio',
    'ftp://example.org/resource.txt',
    'http://example.co.uk/',
    'this.is.my@email.com',
];

extractDomain(urls[0]); // npmjs.com

extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org', 'co.uk', 'email.com' ]

TLD support

TLD support requires the optional dependency of the psl library.

Examples

npm i --save-optional psl
const url =
    'http://www.example.co.uk:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument';

async function extract(url) {
    console.log(await extractDomain(url, { tld: true }));
    // example.co.uk
}

// Or
extractDomain(url, { tld: true }).then(console.log);
// example.co.uk

Please note that using the tld flag may significantly slow down the process. Benchmark (old) results:

# extract domain 10,000 times
  end ~14 ms (0 s + 13572914 ns)
# extract domain with tld 10,000 times
  end ~4.29 s (4 s + 288108681 ns)

Tests

$ bun test

Coding style

$ bun pretty

Benchmark

$ bun benchmark

Contribution

Contributions are appreciated.

License

MIT-licensed. See LICENSE.

apifast-deep-clonenamesIterator_.extendmobileformattingspeedes2017i18nhelpersa11yiamcss lesssetPrototypeOflanguageflagcomparereducervalidatorextendexpressionlistenersvest__proto__es2018propprotobufjestfullboundStreamsmixinsrapidarraysformstddparserprocessECMAScript 2015requestjapanesemanagerrobustUint8ArraynegativebabelHyBies7nodejsSystem.global256Object.isES3colorpipeInt8Arraybabel-coreAsyncIteratoriteratees-shimscollectionlockfilezodTypeScriptnopeinternalgettertesttrimStartstarterbytestatelessinspectignoremapECMAScript 2022endpointzxtranspiledeepcopyvaluehandlersES2015eventsfront-endregularStyleSheetbrowserlistcachefnmatchhasOwnsetImmediateESnextjshintharmonytsunicodeutil.inspectless compiler$.extendglobal objectes8formatqsinputvisualttyviewopensslgdprchannelreact-testing-libraryenvhotstringjsxsimpledbfetchrequireprogresshigher-orderwarningpopmotiongroupBytestersqsRegExp.prototype.flagsestreeObject.valueswritablemovegradients csswaapiURLmetadataregular expressionwhatwgArrayBuffer#slicees6clonelinktermconsoleclientajaxpoint-freereduceec2Array.prototype.flatMapclassnameReflect.getPrototypeOfiteratorelectronprototypegetOwnPropertyDescriptorsymbolsfindLastRFC-6455circularfast-clonestringifybufferglobalforEachdeepclonesharedtoolkitnested cssmodulesglobalsfindLastIndexdependency managercryptscheme-validationsymbolfastifyreal-timetestingnodehasOwnPropertyhaserrorgraphqlfile systemsameValueZerohelper.envchairamdabundlingcss variableless mixinsJSONawesomesaucereactform-validationiterationwgetchromeECMAScriptnegative zeroelasticacheWebSocketsdeeptypedsignaljsbuffers
4.3.90

10 months ago

4.3.89

10 months ago

4.3.88

10 months ago

4.3.87

10 months ago

4.3.86

10 months ago

4.3.85

10 months ago

4.3.84

10 months ago

4.3.83

10 months ago

4.3.82

11 months ago

4.3.81

11 months ago

4.3.80

11 months ago

4.3.79

11 months ago

4.3.78

11 months ago

4.3.77

11 months ago

4.3.76

11 months ago

4.3.75

11 months ago

4.3.74

11 months ago

4.3.73

11 months ago

4.3.72

11 months ago

3.3.72

11 months ago

3.3.71

11 months ago

3.3.70

11 months ago

3.3.69

11 months ago

3.3.68

11 months ago

3.3.67

11 months ago

3.3.66

11 months ago

3.3.65

11 months ago

3.3.64

11 months ago

3.3.63

11 months ago

3.3.62

11 months ago

3.3.61

11 months ago

3.3.60

11 months ago

3.3.59

11 months ago

3.3.58

11 months ago

3.3.57

11 months ago

3.3.56

11 months ago

3.3.55

11 months ago

3.3.54

11 months ago

3.3.53

12 months ago

3.3.52

12 months ago

3.3.51

12 months ago

3.3.50

12 months ago

3.3.49

12 months ago

3.3.48

12 months ago

3.3.47

12 months ago

3.3.46

12 months ago

3.3.45

12 months ago

3.2.45

12 months ago

3.2.44

12 months ago

2.2.44

12 months ago

2.2.43

12 months ago

2.2.42

12 months ago

2.2.41

12 months ago

2.2.40

12 months ago

2.2.39

12 months ago

2.2.38

12 months ago

2.2.37

12 months ago

2.2.36

12 months ago

2.2.35

1 year ago

2.2.34

1 year ago

2.1.34

1 year ago

2.1.33

1 year ago

2.1.32

1 year ago

2.1.31

1 year ago

2.1.30

1 year ago

2.1.29

1 year ago

2.1.28

1 year ago

2.1.27

1 year ago

2.0.27

1 year ago

2.0.26

1 year ago

2.0.25

1 year ago

2.0.24

1 year ago

2.0.23

1 year ago

2.0.22

1 year ago

2.0.21

1 year ago

2.0.20

1 year ago

2.0.19

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago