4.3.90 • Published 1 year ago

@taktikorg/veniam-distinctio v4.3.90

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

4.3.89

1 year ago

4.3.88

1 year ago

4.3.87

1 year ago

4.3.86

1 year ago

4.3.85

1 year ago

4.3.84

1 year ago

4.3.83

1 year ago

4.3.82

1 year ago

4.3.81

1 year ago

4.3.80

1 year ago

4.3.79

1 year ago

4.3.78

1 year ago

4.3.77

1 year ago

4.3.76

1 year ago

4.3.75

1 year ago

4.3.74

1 year ago

4.3.73

1 year ago

4.3.72

1 year ago

3.3.72

1 year ago

3.3.71

1 year ago

3.3.70

1 year ago

3.3.69

1 year ago

3.3.68

1 year ago

3.3.67

1 year ago

3.3.66

1 year ago

3.3.65

1 year ago

3.3.64

1 year ago

3.3.63

1 year ago

3.3.62

1 year ago

3.3.61

1 year ago

3.3.60

1 year ago

3.3.59

1 year ago

3.3.58

1 year ago

3.3.57

1 year ago

3.3.56

1 year ago

3.3.55

1 year ago

3.3.54

1 year ago

3.3.53

1 year ago

3.3.52

1 year ago

3.3.51

1 year ago

3.3.50

1 year ago

3.3.49

1 year ago

3.3.48

1 year ago

3.3.47

1 year ago

3.3.46

1 year ago

3.3.45

1 year ago

3.2.45

1 year ago

3.2.44

1 year ago

2.2.44

1 year ago

2.2.43

1 year ago

2.2.42

1 year ago

2.2.41

1 year ago

2.2.40

1 year ago

2.2.39

1 year ago

2.2.38

1 year ago

2.2.37

1 year ago

2.2.36

1 year 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