Socket
Socket
Sign inDemoInstall

slugify-url

Package Overview
Dependencies
0
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.1

9

index.js

@@ -8,2 +8,3 @@ "use strict";

maxLength: 100,
unixOnly: false, /* if true do not care for windows compatibility.. any non / char is ok */
skipProtocol: true,

@@ -48,5 +49,11 @@ skipUserPass: true

/* skip slashes for slashChar */
/* replace slashes with slashChar */
sanitized = sanitized.replace(/\//g, options.slashChar);
/* replace windows invalid chars with slashChar */
/* based on http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29 */
if (!options.unixOnly) {
sanitized = sanitized.replace(/[<>:"/\\|?*]/g, options.slashChar);
}
/* truncate to max length */

@@ -53,0 +60,0 @@ sanitized = sanitized.substr(0, options.maxLength);

2

package.json

@@ -11,3 +11,3 @@ {

],
"version": "1.0.2",
"version": "1.1.1",
"repository": {

@@ -14,0 +14,0 @@ "type": "git",

@@ -14,2 +14,3 @@ Converts urls to simplified strings

- It maps slashes to !
- Unless a unixOnly option is given it maps all windows invalid chars to !
- It truncates the URL to 100 chars

@@ -24,3 +25,5 @@ - It includes an optional options argument that allows the user to override the behavior

- https://www.odesk.com/mc/ => www.odesk.com!mc
- http://www.genecards.org/cgi-bin/carddisp.pl?gene=STH => www.genecards.org!cgi-bin!carddisp.pl?gene=STH
- http://www.genecards.org/cgi-bin/carddisp.pl?gene=STH => www.genecards.org!cgi-bin!carddisp.pl!gene=STH
or if unixOnly is true
http://www.genecards.org/cgi-bin/carddisp.pl?gene=STH => www.genecards.org!cgi-bin!carddisp.pl?gene=STH
- http://odysseas:secret@www.mysite.com/test.html => www.mysite.com/test.html

@@ -27,0 +30,0 @@

@@ -24,3 +24,3 @@ /*

t.equal(slugify_url("https://www.odesk.com/mc/"), "www.odesk.com!mc!");
t.equal(slugify_url("https://www.odesk.com/mc/", {skipProtocol: false}), "https:!!www.odesk.com!mc!");
t.equal(slugify_url("https://www.odesk.com/mc/", {skipProtocol: false}), "https!!!www.odesk.com!mc!");
t.equal(slugify_url("https://admin:test@www.odesk.com"), "www.odesk.com");

@@ -35,1 +35,7 @@ t.end();

});
test("test if slugify-url fixes windows invalid characters", function (t) {
t.equal(slugify_url("https://www.odesk.com?q=a+b!c*d|e\"f'g/h<i>j\\k"), "www.odesk.com!q=a+b!c!d!e!f'g!h!i!j!k");
t.equal(slugify_url("https://www.odesk.com?q=a+b!c*d|e\"f'g/h<i>j\\k",{unixOnly: true}), "www.odesk.com?q=a+b!c*d|e\"f'g!h<i>j\\k");
t.end();
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc