super-trailing-slash

Add or remove trailing slash

Usage no npm install needed!

<script type="module">
  import superTrailingSlash from 'https://cdn.skypack.dev/super-trailing-slash';
</script>

README

super-trailing-slash

Remove or add trailing slash.

Installation

Node.js

npm install super-trailing-slash --save

Example

Add trailing slash

const slash = require('super-trailing-slash');

slash.add('path/to/file'); //=> path/to/file/
slash.add('\\path\\to\\file'); //=> \path\to\file\

// Adds only if necessary
slash.add('path/to/file/'); //=> path/to/file/

Remove trailing slash

slash.remove('path/to/file/'); //=> path/to/file
slash.remove('\\path\\to\\file\\'); //=> \path\to\file

// Removes only if necessary
slash.remove('path/to/file'); //=> path/to/file

API

See full documentation

Changelog

You can view the changelog here

License

super-trailing-slash is open-sourced software licensed under the MIT license

Author

Fabio Ricali