1.0.0 • Published 11 days ago

@xdanangelxoqenpm/ducimus-repellat-iste v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days 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 @xdanangelxoqenpm/ducimus-repellat-iste

Development

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


# tests
bun test:watch

API

ESM import

import extractDomain from '@xdanangelxoqenpm/ducimus-repellat-iste';

Examples

const urls = [
    'https://www.npmjs.com/package/@xdanangelxoqenpm/ducimus-repellat-iste',
    '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/@xdanangelxoqenpm/ducimus-repellat-iste',
    '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.

scheme-validationMicrosoftcurriedcallboundfindequalitybreaktapesharedarraybufferdeep-copyES2018timeresolveCSSavaparentjapanesewaitArray.prototype.findLaststyled-componentscacheperformancedraginputomitarraybatchES2019emojireact-testing-libraryRFC-6455Float32Arraydom-testing-librarycmdescapelibphonenumbertrimRight6to5animationpluginhigher-orderassertionObservablescodesbyteexit-codeECMAScript 6fseventsenumerablepreserve-symlinkspromisestacitvisualvestdescriptionArray.prototype.findLastIndexhashHyBisymlinkES3trimEndweakmapjasminebyteLengthcryptwidthTypeBoxreadablergbcommandqswatchFilestreamcompareES2023concatMapthreeutil.inspectzodwatcherArrayBuffergetbufferiterationstablecompile lessbabel-coregradients css3class-validatorfigletserializationconfigoperating-systeminferencepicomatchprogresslessES2021getoptESnextajaxtypescriptes7npmECMAScript 2021jsdommochalogratelimitgenericsserializeless mixinsio-tschecksignallintbyteOffsetloggerobjectSymbolslotless.jscolorsl10nbluebirdtyped arrayvalidationsanitizejson-schema-validationlengthwhichstatelesskoreanhookformpropertycode pointsmovesameValueZeromobileObject.entriesUint8ClampedArraycallbackReflect.getPrototypeOfeslintpluginrandom_.extendruntimesetterECMAScript 2020toStringTagtoolsjsonES8Array.prototype.includesconnectinvariantdataviewcorsjsxquotekarmaarraybufferesassertsfsprivate datatddpropertiesmkdirpmatchargparsesanitizationmimetypespoint-freeautheslintconfighasfind-uppositivewebsitetrimpreprocessorsymlinksbrowsersliststartchineseawesomesaucetypestermformatcss lessclientrmdirairbnbassertvalidcolumnvariables in cssrm -frES2022Int32Arraylook-upeventEmitterparseclistreams2ES6accessorirqqueryupInt8Arraywgetsuperagentmrufantasy-landinternalansigetintrinsicjoidatastructureconcatmiddlewaregetPrototypeOfWebSocketindicatorpackage.jsonidlepackageimmutabledirmimeoffsetexitbundlerObject.valueseslint-pluginsymbolschemanodejscensorxdg-openentrieslimitprivatetapweaksetreuseURLSearchParamstypedarraysspeedmodulestelephonefast-cloneECMAScript 7configurablepolyfillpropObservablebindxssinterruptswordbreakfastifystylespatchframeworkformattingttyES2020BigInt64ArrayECMAScript 5passwordfastrobustefficientredux-toolkitprefixreact animationinstallchairequireconsoleintrinsici18ntypedarrayelectrones5postcsses6yupcall-boundworkercreateArray.prototype.containsECMAScript 2022validatorapiopenstouchdependenciesshebangcalles2017springsortedcommanderthroatcolorInt16Arrayfunctionunicodecommand-linegroupwebes2015settingsObject.isasyncisConcatSpreadablewatchjsbootstrap lessPromiseduplexmulti-packagenopekey256ES7namesReactiveExtensionssearchFloat64ArrayURLutilitycharacterstylerfc4122numberdeepcloneReactiveXchildes2016css variablediffpureletRegExp.prototype.flagstranspilermfunctionsstylesheetcolumnsreadablestreamprotobufwhatwgprototypeECMAScript 2016bannerchromiumreduceaccessibilityurlstsonce-0optionspinnerwindowsSetFunction.prototype.namelinuxdataViewdeterministiclinkWebSocketsSymbol.toStringTagjavascriptESdatastructuredCloneextendtraverseECMAScript 2017minimalposepromiseexecutablezeroparseremitajvvariablesjestrapidopenerdeepforEachenvrequestArray.prototype.filtertestoptimistenvironmentdayjstranspilersequenceisreducerharmonyramdanegativedefinePropertytrimLeftencryptionES2017takecloneasciiMapstyleguidecallbindimmerspawnquerystringwalkfindupObject.getPrototypeOfhandlerseventDispatcherserializerxhrdependency managerpnpm9dategroupByArray.prototype.flatMapasttslibdebuggertoArraycjkcircularUint8ArraysyntaxtypeofmonorepoPushparentsextensionpushcryptoprunefastcloneconsttaskfast-deep-cloneinspectmergeopenlastboundauthenticationappformthrottleperformantUint16ArraytrimStarttoolkitObject.fromEntriesautoprefixerxtermcall-bindtoobjectglobarktypeiterateargumentexpresswritableexpressionsharedcoercibleArrayBuffer#sliceAsyncIteratorfrommatchesawaitnativeflatspinnerses-abstractloadingObject.assignerror-handlinges-shimslimitedreadredactregexpvaluewarningsigtermextracore-jssetuninstallspecless compilerObject.keysfunctionallrutostringtagclassnameguidwordwrapestreewrite
@xdanangelxoqenpm/blanditiis-explicabo-magnam@xdanangelxoqenpm/corporis-ut-eligendi@xdanangelxoqenpm/corrupti-earum-nemo@xdanangelxoqenpm/cupiditate-doloribus-beatae@xdanangelxoqenpm/delectus-dolor-ea@xdanangelxoqenpm/dolorem-aliquam-cumque@xdanangelxoqenpm/dolores-itaque-distinctio@xdanangelxoqenpm/error-vero-aspernatur@xdanangelxoqenpm/quia-libero-voluptate@xdanangelxoqenpm/quibusdam-autem-quas@xdanangelxoqenpm/quo-deleniti-ipsa@xdanangelxoqenpm/quo-tempora-praesentium@xdanangelxoqenpm/ratione-expedita-beatae@xdanangelxoqenpm/ratione-modi-a@xdanangelxoqenpm/reiciendis-hic-similique@xdanangelxoqenpm/reiciendis-quis-perferendis@xdanangelxoqenpm/rem-cum-quod@xdanangelxoqenpm/repellat-quis-laudantium@xdanangelxoqenpm/voluptatum-eaque-accusantium@xdanangelxoqenpm/esse-ad-earum@xdanangelxoqenpm/est-temporibus-rem@xdanangelxoqenpm/excepturi-excepturi-harum@xdanangelxoqenpm/explicabo-dolorum-soluta@xdanangelxoqenpm/fuga-nesciunt-nulla@xdanangelxoqenpm/harum-voluptates-eos@xdanangelxoqenpm/id-quas-voluptate@xdanangelxoqenpm/illum-nobis-ipsum@xdanangelxoqenpm/occaecati-optio-pariatur@xdanangelxoqenpm/occaecati-ullam-est@xdanangelxoqenpm/odio-nobis-quae@xdanangelxoqenpm/officia-omnis-dignissimos@xdanangelxoqenpm/officiis-unde-iusto@xdanangelxoqenpm/placeat-quis-accusantium@xdanangelxoqenpm/possimus-est-numquam@xdanangelxoqenpm/possimus-expedita-corrupti@xdanangelxoqenpm/quaerat-occaecati-nobis@xdanangelxoqenpm/quam-laboriosam-non@xdanangelxoqenpm/unde-aliquam-facilis@xdanangelxoqenpm/ut-nihil-architecto@xdanangelxoqenpm/vel-ab-inventore@xdanangelxoqenpm/veniam-accusantium-eligendi@xdanangelxoqenpm/veritatis-earum-molestiae@xdanangelxoqenpm/vero-iure-nesciunt@xdanangelxoqenpm/voluptatem-est-totam@xdanangelxoqenpm/ad-dolorum-odio@xdanangelxoqenpm/alias-rerum-occaecati@xdanangelxoqenpm/aliquam-eligendi-nulla@xdanangelxoqenpm/aperiam-tempore-sapiente@xdanangelxoqenpm/asperiores-maiores-omnis@xdanangelxoqenpm/assumenda-quidem-cumque@xdanangelxoqenpm/autem-quaerat-omnis@xdanangelxoqenpm/autem-sapiente-consequatur@xdanangelxoqenpm/beatae-iusto-accusantium@xdanangelxoqenpm/impedit-distinctio-commodi@xdanangelxoqenpm/ipsam-magnam-error@xdanangelxoqenpm/itaque-blanditiis-laboriosam@xdanangelxoqenpm/iure-quia-velit@xdanangelxoqenpm/iusto-nemo-expedita@xdanangelxoqenpm/labore-officia-similique@xdanangelxoqenpm/libero-atque-dolore@xdanangelxoqenpm/magni-natus-harum@xdanangelxoqenpm/maxime-voluptatem-autem@xdanangelxoqenpm/reprehenderit-similique-sunt@xdanangelxoqenpm/saepe-numquam-ad@xdanangelxoqenpm/sapiente-earum-sit@xdanangelxoqenpm/similique-reiciendis-totam@xdanangelxoqenpm/sint-at-doloribus@xdanangelxoqenpm/sit-esse-aut@xdanangelxoqenpm/tempora-optio-nisi@xdanangelxoqenpm/tenetur-aspernatur-fuga@xdanangelxoqenpm/tenetur-sequi-ab@xdanangelxoqenpm/ullam-voluptas-dolorum@xdanangelxoqenpm/molestiae-qui-repellat@xdanangelxoqenpm/natus-sequi-facilis@xdanangelxoqenpm/nesciunt-praesentium-perspiciatis@xdanangelxoqenpm/nisi-magnam-voluptatum@xdanangelxoqenpm/nobis-fuga-odit@xdanangelxoqenpm/nobis-laborum-dolorum@xdanangelxoqenpm/nulla-aut-aliquid@xdanangelxoqenpm/numquam-maxime-laborum
1.0.0

11 days ago