Native Package Manager

    url-extension-validator

    1.2.1 • Public • Published

    url-extension-validator

    standard-readme compliant

    Methods for validating URL web page extensions (ending in .aspx, .php, .htm, .html ...)

    Check if the supplied URL ends in a known web page extension or not. The valid extensions list can be overridden for custom use cases.

    Table of Contents

    Install

    npm install --save url-extension-validator

    Usage

    const UrlExtensionValidator = require('url-extension-validator');
     
    const validator = new UrlExtensionValidator();

    To check if a URL ends in a valid web page extension

    const validUrl = validator.matchValidExtension('https://example.com/index.php'); // => true

    To check if a web page extension is valid or not

    const validExtension = validator.validateExtension('.html'); // => true
    const alsoValid = validator.validateExtension('html'); // => true

    To return an array of valid web page extensions for any use case (i.e. custom map, filter or reduce functions)

    const validExtensions = UrlExtensionValidator.extensions(); // => ['.asp', '.aspx', ...]

    To return a simple map of valid web page extensions

    const validExtensionMap = validator.extensionMap(); // => { '.asp': true, '.aspx': true, ... }

    To wrap any method in a promise

    validator.chain( validator.validateExtension('.cgi') )
        .then(result // => true)
        .then(...) // do something async
        

    To override the valid extensions list

    const validator = new UrlExtensionsValidator({ extensionsList: ['.htm', '.html', '.btc'] });
     
    const validExtension = validator.validateExtension('.php'); // => false

    Maintainers

    @njhoran

    Contributing

    Small note: If editing the README, please conform to the standard-readme specification.

    License

    MIT © 2019 njhoran

    Install

    npm i url-extension-validator

    DownloadsWeekly Downloads

    1

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    13.5 kB

    Total Files

    8

    Last publish

    Collaborators

    • njhoran