Newfoundland Pitbull Mix

    you-are-el

    0.0.4 • Public • Published

    Url and path formatting helper for node/browser

    Useful for sanitizing user input or output data.

    var youAreEl = require('you-are-el');
     
    youAreEl('https://facebook.com/foo/bar/').toPath();
    youAreEl('http://facebook.com/foo/bar/').toPath();
    youAreEl('facebook.com/foo/bar/').toPath();
    youAreEl('/foo/bar/').toPath();
    youAreEl('foo/bar/').toPath();
    // all equal 'foo/bar'
     
    youAreEl('foo/bar').toUrl('facebook.com');
    youAreEl('foo/bar').toUrl('http://facebook.com');
    youAreEl('foo/bar').toUrl({ host: 'facebook.com' });
    // all equal 'http://facebook.com/foo/bar'
     
    // Specify protocol option
    youAreEl('foo/bar').toUrl({ protocol: 'https', host: 'facebook.com'});
    // equals 'https://facebook.com/foo/bar'
     
    // Omit protocol
    youAreEl('foo/bar').toUrl({ protocol: false, host: 'facebook.com'});
    // equals 'facebook.com/foo/bar'
     
    // Specify host option
    youAreEl('foo/bar').toUrl({ host: 'twitter.com'});
    // equals 'twitter.com/foo/bar'

    Keywords

    none

    Install

    npm i you-are-el

    DownloadsWeekly Downloads

    2

    Version

    0.0.4

    License

    BSD-2-Clause

    Last publish

    Collaborators

    • moudy