New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

crop-url

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crop-url

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

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
886
decreased by-20.75%
Maintainers
1
Weekly downloads
 
Created
Source

crop-url

Build Status Coverage Status Dependencies Status NPM version

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

Install

npm i crop-url --save

Usage

const cropUrl = require('crop-url');

let url = cropUrl('http://www.foobar.com/abc/def/ghi/index.html', 26);
console.log(url) //=> 'foobar.com/…/index.html'

url = cropUrl('https://www.foobar.com/abc/def/ghi/jkl/', 26);
console.log(url) //=> 'foobar.com/abc/def/…/jkl/'

url = cropUrl('http://www.foobar.com/abc/def/ghi/jkl/', 1);
console.log(url) //=> 'foobar.com/…/jkl/'

url = cropUrl('http://www.foobar.com/search/?q=foo&page=bar', 35);
console.log(url) //=> 'foobar.com/search/?q=foo&page=bar'

url = cropUrl('http://www.foobar.com/search/?q=foo&page=bar', 20);
console.log(url) //=> 'foobar.com/…/?q=foo…'

url = cropUrl('http://www.foobar.com/search/?q=foo&page=bar', 12);
console.log(url) //=> 'foobar.com/…/?…'

url = cropUrl('http://www.foobar.com/foo-bar-foo-bar.html', 12);
console.log(url) //=> 'foobar.com/foo…'

Contributing

Contributions are always welcome.

See Contributing.

Developer

License

The MIT License (MIT)

Keywords

FAQs

Package last updated on 21 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc