Nocturnal Parakeet Monitor

    @braintree/sanitize-url
    TypeScript icon, indicating that this package has built-in type declarations

    6.0.2 • Public • Published

    sanitize-url

    Installation

    npm install -S @braintree/sanitize-url

    Usage

    var sanitizeUrl = require("@braintree/sanitize-url").sanitizeUrl;
    
    sanitizeUrl("https://example.com"); // 'https://example.com'
    sanitizeUrl("http://example.com"); // 'http://example.com'
    sanitizeUrl("www.example.com"); // 'www.example.com'
    sanitizeUrl("mailto:hello@example.com"); // 'mailto:hello@example.com'
    sanitizeUrl(
      "https&#0000058//example.com"
    ); // https://example.com
    
    sanitizeUrl("javascript:alert(document.domain)"); // 'about:blank'
    sanitizeUrl("jAvasCrIPT:alert(document.domain)"); // 'about:blank'
    sanitizeUrl(decodeURIComponent("JaVaScRiP%0at:alert(document.domain)")); // 'about:blank'
    // HTML encoded javascript:alert('XSS')
    sanitizeUrl(
      "&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041"
    ); // 'about:blank'

    Keywords

    none

    Install

    npm i @braintree/sanitize-url

    DownloadsWeekly Downloads

    867,182

    Version

    6.0.2

    License

    MIT

    Unpacked Size

    16.6 kB

    Total Files

    16

    Last publish

    Collaborators

    • braintree