Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pathifist

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathifist - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

5

CHANGELOG.md

@@ -5,3 +5,8 @@ # Change Log

<a name="0.0.2"></a>
## [0.0.2](https://github.com/untool/pathifist/compare/v0.0.1...v0.0.2) (2018-10-16)
<a name="0.0.1"></a>
## 0.0.1 (2018-10-16)

16

index.js

@@ -35,20 +35,20 @@ 'use strict';

exports.trimLeadingSlashes = function trimLeadingSlashes(path) {
exports.ensureSlashes = function ensureSlashes(path) {
return path.replace(/^\/*(.*?)\/*$/, '/$1/');
};
exports.trimLeadingSlash = function trimLeadingSlash(path) {
return path.replace(/^\/+/, '');
};
exports.trimTrailingSlashes = function trimTrailingSlashes(path) {
exports.trimTrailingSlash = function trimTrailingSlash(path) {
return path.replace(/\/+$/, '');
};
exports.ensureSlashes = function ensureSlashes(path) {
return path.replace(/^\/*(.*?)\/*$/, '/$1/');
};
exports.ensureLeadingSlashes = function ensureLeadingSlashes(path) {
exports.ensureLeadingSlash = function ensureLeadingSlash(path) {
return path.replace(/^\/*/, '/');
};
exports.ensureTrailingSlashes = function ensureTrailingSlashes(path) {
exports.ensureTrailingSlash = function ensureTrailingSlash(path) {
return path.replace(/\/*$/, '/');
};
{
"name": "pathifist",
"version": "0.0.1",
"version": "0.0.2",
"description": "URL Path Utility",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -49,20 +49,20 @@ # pathifist

#### `trim{Leading,Trailing}Slashes(path)`
#### `trimSlashes(path)` / `trim{Leading,Trailing}Slash(path)`
`trim{Leading,Trailing}Slashes` removes single or consecutive leading and/or trailing slashes from the `path` it is being passed. It leaves internal slashes untouched.
`trimSlashes` / `trim{Leading,Trailing}Slash` removes single or consecutive leading and/or trailing slashes from the `path` it is being passed. It leaves internal slashes untouched.
```javascript
trimSlashes('/foo/bar/'); // => foo/bar
trimLeadingSlashes('/foo/bar/'); // => foo/bar/
trimTrailingSlashes('/foo/bar/'); // => /foo/bar
trimLeadingSlash('/foo/bar/'); // => foo/bar/
trimTrailingSlash('/foo/bar/'); // => /foo/bar
```
#### `ensure{Leading,Trailing}Slashes(path)`
#### `ensureSlashes(path)` / `ensure{Leading,Trailing}Slash(path)`
`ensure{Leading,Trailing}Slashes` makes sure there are single or consecutive leading and/or trailing slashes in the `path` it is being passed. It leaves internal slashes untouched.
`ensureSlashes` / `ensure{Leading,Trailing}Slash` makes sure there are single or consecutive leading and/or trailing slash in the `path` it is being passed. It leaves internal slash untouched.
```javascript
ensureSlashes('foo/bar'); // => /foo/bar/
ensureLeadingSlashes('foo/bar'); // => /foo/bar
ensureTrailingSlashes('foo/bar'); // => foo/bar/
ensureLeadingSlash('foo/bar'); // => /foo/bar
ensureTrailingSlash('foo/bar'); // => foo/bar/
```
var test = require('ava');
var pathifist = require('./index');

@@ -6,12 +7,13 @@

var join = pathifist.join;
var dedupe = pathifist.dedupeSlashes;
var trim = pathifist.trimSlashes;
var trimLeading = pathifist.trimLeadingSlashes;
var trimTrailing = pathifist.trimTrailingSlashes;
var ensure = pathifist.ensureSlashes;
var ensureLeading = pathifist.ensureLeadingSlashes;
var ensureTrailing = pathifist.ensureTrailingSlashes;
var trimLeading = pathifist.trimLeadingSlash;
var trimTrailing = pathifist.trimTrailingSlash;
var ensureLeading = pathifist.ensureLeadingSlash;
var ensureTrailing = pathifist.ensureTrailingSlash;
test('exports test', function(t) {

@@ -22,7 +24,7 @@ t.is(typeof join, 'function', 'join is a function');

t.is(typeof trim, 'function', 'trimSlashes is a function');
t.is(typeof trimLeading, 'function', 'trimLeadingSlashes is a function');
t.is(typeof trimTrailing, 'function', 'trimTrailingSlashes is a function');
t.is(typeof ensure, 'function', 'ensureSlashes is a function');
t.is(typeof ensureLeading, 'function', 'ensureLeadingSlashes is a function');
t.is(typeof ensureTrailing, 'function', 'ensureTrailingSlashes is function');
t.is(typeof trimLeading, 'function', 'trimLeadingSlash is a function');
t.is(typeof trimTrailing, 'function', 'trimTrailingSlash is a function');
t.is(typeof ensureLeading, 'function', 'ensureLeadingSlash is a function');
t.is(typeof ensureTrailing, 'function', 'ensureTrailingSlash is a function');
});

@@ -60,3 +62,8 @@

test('trimLeadingSlashes test', function(t) {
test('ensureSlashes test', function(t) {
t.is(ensure('foo/bar'), '/foo/bar/', 'ensure works');
t.is(ensure('//foo//bar//'), '/foo//bar/', 'multi ensure works');
});
test('trimLeadingSlash test', function(t) {
t.is(trimLeading('/foo/bar/'), 'foo/bar/', 'trimLeading works');

@@ -66,3 +73,3 @@ t.is(trimLeading('//foo//bar//'), 'foo//bar//', 'multi trimLeading works');

test('trimTrailingSlashes test', function(t) {
test('trimTrailingSlash test', function(t) {
t.is(trimTrailing('/foo/bar/'), '/foo/bar', 'trimTrailing works');

@@ -72,8 +79,3 @@ t.is(trimTrailing('//foo//bar//'), '//foo//bar', 'multi trimTrailing works');

test('ensureSlashes test', function(t) {
t.is(ensure('foo/bar'), '/foo/bar/', 'ensure works');
t.is(ensure('//foo//bar//'), '/foo//bar/', 'multi ensure works');
});
test('ensureLeadingSlashes test', function(t) {
test('ensureLeadingSlash test', function(t) {
t.is(ensureLeading('foo/bar'), '/foo/bar', 'ensureLeading works');

@@ -83,5 +85,5 @@ t.is(ensureLeading('//foo//bar'), '/foo//bar', 'multi ensureLeading works');

test('ensureTrailingSlashes test', function(t) {
test('ensureTrailingSlash test', function(t) {
t.is(ensureTrailing('foo/bar'), 'foo/bar/', 'ensureTrailing works');
t.is(ensureTrailing('foo//bar//'), 'foo//bar/', 'multi ensureTrailing works');
});
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