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

safe-join

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-join - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

13

dist/safeJoin.cjs.development.js

@@ -6,14 +6,5 @@ 'use strict';

}
// thanks to https://twitter.com/swyx/status/1106839872096985088
function _safeJoin(a, b) {
let isTrailingSlash, isLeadingSlash;
if (a.length > 1 && a.slice(-1)[0] === '/')
isTrailingSlash = true;
if (b.length > 1 && b[0] === '/')
isLeadingSlash = true;
if (isTrailingSlash && isLeadingSlash)
return a + b.slice(1);
else if (!isTrailingSlash && !isLeadingSlash)
return a + '/' + b;
else
return a + b;
return a.replace(/\/$/, '') + '/' + b.replace(/^\//, '');
}

@@ -20,0 +11,0 @@

2

dist/safeJoin.cjs.production.js

@@ -1,2 +0,2 @@

"use strict";function e(e,t){let n,r;return e.length>1&&"/"===e.slice(-1)[0]&&(n=!0),t.length>1&&"/"===t[0]&&(r=!0),n&&r?e+t.slice(1):n||r?e+t:e+"/"+t}exports.safeJoin=function(...t){return t.reduce(e)};
"use strict";function e(e,r){return e.replace(/\/$/,"")+"/"+r.replace(/^\//,"")}exports.safeJoin=function(...r){return r.reduce(e)};
//# sourceMappingURL=safeJoin.cjs.production.js.map

@@ -1,2 +0,2 @@

function e(...e){return e.reduce(n)}function n(e,n){let t,r;return e.length>1&&"/"===e.slice(-1)[0]&&(t=!0),n.length>1&&"/"===n[0]&&(r=!0),t&&r?e+n.slice(1):t||r?e+n:e+"/"+n}export{e as safeJoin};
function e(...e){return e.reduce(r)}function r(e,r){return e.replace(/\/$/,"")+"/"+r.replace(/^\//,"")}export{e as safeJoin};
//# sourceMappingURL=safeJoin.es.production.js.map

@@ -10,14 +10,5 @@ (function (global, factory) {

}
// thanks to https://twitter.com/swyx/status/1106839872096985088
function _safeJoin(a, b) {
let isTrailingSlash, isLeadingSlash;
if (a.length > 1 && a.slice(-1)[0] === '/')
isTrailingSlash = true;
if (b.length > 1 && b[0] === '/')
isLeadingSlash = true;
if (isTrailingSlash && isLeadingSlash)
return a + b.slice(1);
else if (!isTrailingSlash && !isLeadingSlash)
return a + '/' + b;
else
return a + b;
return a.replace(/\/$/, '') + '/' + b.replace(/^\//, '');
}

@@ -24,0 +15,0 @@

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e["safe-join"]={})}(this,function(e){"use strict";function n(e,n){let t,i;return e.length>1&&"/"===e.slice(-1)[0]&&(t=!0),n.length>1&&"/"===n[0]&&(i=!0),t&&i?e+n.slice(1):t||i?e+n:e+"/"+n}e.safeJoin=function(...e){return e.reduce(n)}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e["safe-join"]={})}(this,function(e){"use strict";function n(e,n){return e.replace(/\/$/,"")+"/"+n.replace(/^\//,"")}e.safeJoin=function(...e){return e.reduce(n)}});
//# sourceMappingURL=safeJoin.umd.production.js.map
{
"name": "safe-join",
"version": "0.1.2",
"version": "0.1.3",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "umd:main": "dist/safe-join.umd.production.js",

@@ -37,13 +37,8 @@ # Safe Join

```ts
export default function safeJoin(...args: string[]) {
export function safeJoin(...args: string[]) {
return args.reduce(_safeJoin)
}
// thanks to https://twitter.com/swyx/status/1106839872096985088
function _safeJoin(a: string, b: string) {
let isTrailingSlash, isLeadingSlash
if (a.length > 1 && a.slice(-1)[0] === '/') isTrailingSlash = true
if (b.length > 1 && b[0] === '/') isLeadingSlash = true
if (isTrailingSlash && isLeadingSlash) return a + b.slice(1)
else if (!isTrailingSlash && !isLeadingSlash) return a + '/' + b
else return a + b
return a.replace(/\/$/, '') + '/' + b.replace(/^\//, '')
}

@@ -50,0 +45,0 @@ ```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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