npm

Join us for the "JavaScript Supply Chain Security" tech talk, presented by VP of Security, Adam Baldwin. 6/20 at 10am PT.Sign up here »

crop-url

2.0.1 • Public • Published

crop-url

Build Status Coverage Status Dependency Status NPM version

Truncate a url so that it doesn't appear so long visually

Install

npm i crop-url --save

Usage

var cropUrl = require('crop-url');
 
cropUrl('http://www.foobar.com/abc/def/ghi/index.html', 26);
//=> 'foobar.com/…/index.html'
 
cropUrl('https://www.foobar.com/abc/def/ghi/jkl/', 26);
//=> 'foobar.com/abc/def/…/jkl/'
 
cropUrl('http://www.foobar.com/abc/def/ghi/jkl/', 1);
//=> 'foobar.com/…/jkl/'
 
cropUrl('http://www.foobar.com/search/?q=foo&page=bar', 35);
//=> 'foobar.com/search/?q=foo&page=bar'
 
cropUrl('http://www.foobar.com/search/?q=foo&page=bar', 20);
//=> 'foobar.com/…/?q=foo…'
 
cropUrl('http://www.foobar.com/search/?q=foo&page=bar', 12);
//=> 'foobar.com/…/?…'
 
cropUrl('http://www.foobar.com/foo-bar-foo-bar.html', 12);
//=> 'foobar.com/foo…'

Contributing

Contributions are always welcome.

See Contributing.

Developer

License

The MIT License (MIT)

install

npm i crop-url

Downloadsweekly downloads

351

version

2.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability