1.0.0 • Published 1 year ago

@hutechtechnical/odio-nisi-delectus-quidem v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

URL Validator Kit

A Node.js module to check whether a string is a valid URL.

Installation

Install the package via npm:

npm install @hutechtechnical/odio-nisi-delectus-quidem --save

Usage

Import the module into your project:

const { isUrl } = require('@hutechtechnical/odio-nisi-delectus-quidem');

const url = 'https://www.example.com';
const isValidUrl = isUrl(url);

if (isValidUrl) {
  console.log('Valid URL');
} else {
  console.log('Not a valid URL');
}

The isUrl function returns true if the provided string is a valid URL; otherwise, it returns false.

API

  1. isUrl(text) Checks whether the provided string text is a valid URL.

    - `text`: The string to be checked.
    
    Returns `true` if `text` is a valid URL; otherwise, returns `false`.
  2. isValidUrl(url, callback):

    • url (string): The URL to validate.

    • callback (Function): A callback function to handle the result. Parameters:

      • err (Error | null): An error object if an error occurs; otherwise, null.
      • isValid (boolean | undefined): true if the URL responds with a successful status code; false or undefined in case of an error.

Example

isUrl: Check if a string is a valid URL.

const { isUrl } = require('@hutechtechnical/odio-nisi-delectus-quidem');

const url = 'https://www.example.com';
const isValidUrl = isUrl(url);

console.log(isValidUrl); // Output: true

isValidUrl: Check if a URL responds with a successful status code (2xx or 3xx).

const { isValidUrl } = require('@hutechtechnical/odio-nisi-delectus-quidem');

const url = 'https://www.example.com';
isValidUrl(url, (err, isValid) => {
    if (err) {
        console.error(err); // Handle error
    } else {
        console.log(isValid); // Output: true or false
    }
});

Testing

To run the tests, use:

npm test
efficientspeedreadablestreamawaitfind-upsortedyamlarraybufferwafpolyfillthrottlesyntaxdirectoryminimalrangeerrorcloudformationtermebssyntaxerrorsetImmediatetypestouchtypedviewio-tsdataViewyuptslibcall-boundoptionfolderMapinstallSetsymlinkdirspinnerjsxextendeslintplugintypeofrandom$.extendloggingESWeakSetsymlinksnegative zerobrowserquotechaiInt8ArrayfindLasteventEmitter.envlook-upformattinges6typanionparentspostcss-plugincsskarmamatchestaskjestlocationequalstructuredCloneArrayBuffer.prototype.slicefastcloneECMAScript 2016ownpathrouteimport0iterateansiredactObservablesenderlintajvdataviewpackage.jsoncolorsreact animationappgetterwordwrapcommand-linemimetypesargumentsparsingcharsetRxJScoercibleastagentstatelessbddposetoolsmapreduceregular expressionthreeCSSprefixoffsetapicensortesttimettyeast-asian-widthworkspace:*awsJSON-SchemapackageratelimitES2018make dirES2021arrayprivate dataunicodecreatedescriptorpackageslengthtraversejoistablestarterthroatassignclikinesisFloat32ArrayjsdomECMAScript 2021isgetintrinsicfastifylibphonenumbercommandstylees-abstractprivateES2016fullwidthECMAScript 2023Object.keysglobhasOwnglobalscallbackxdgroute53inferencereact-hookspatchECMAScript 2022ObjectlimitedECMAScript 2017grouponceUint8Arrayreact-hook-formidleECMAScript 3serializationsidematchES6typedarrayswaitcallargvtostringtagesstreamsconvertloadingweaksetcloudwatchstylingpipeerrorflattenenvironmentredux-toolkithashwhatwgincludesES2015Streamtakebeanstalkexeuuidnameexpressionclass-validatorcacheidentifiersloggerjasmineendpointkoreancss-in-jsdeterministicRegExp.prototype.flagssnsvaluefinduptyped arrayjsonnamescomparesafeexpressexecutableshebanglanguage_.extenddatastructure-0waapicheckObject.entriespopmotiondynamodbdrops3intrinsicqueueMicrotasklinkutilsimpledbajaxchromiumreducerinternal slotjapanesecjkprogresscontainsArray.prototype.includesglobalcompilerinstallerespreevarsURLSearchParamsArrayBuffer#slice
1.0.0

1 year ago