Socket
Socket
Sign inDemoInstall

relateurl

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.4 to 0.2.5

11

lib/format.js

@@ -44,6 +44,7 @@ "use strict";

var relativePath = urlObj.path.relative.string;
var resource = showResource(urlObj, options);
if (urlObj.extra.relation.maximumHost || options.output==constants.ABSOLUTE || options.output==constants.ROOT_RELATIVE)
{
str += absolutePath;
str = absolutePath;
}

@@ -56,4 +57,3 @@ else if (relativePath.length<=absolutePath.length && options.output==constants.SHORTEST || options.output==constants.PATH_RELATIVE)

{
var resource = showResource(urlObj,options);
var query = showQuery(urlObj,options) && !!getQuery(urlObj,options);
var query = showQuery(urlObj,options) && !!getQuery(urlObj,options);

@@ -75,2 +75,7 @@ if (urlObj.extra.relation.maximumPath && !resource)

if ( str=="/" && !resource && options.removeRootTrailingSlash && (!urlObj.extra.relation.minimumPort || options.output==constants.ABSOLUTE) )
{
str = "";
}
return str;

@@ -77,0 +82,0 @@ }

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

removeEmptyQueries: false,
removeRootTrailingSlash: true,
schemeRelative: true,

@@ -26,0 +27,0 @@ site: undefined,

{
"name": "relateurl",
"description": "Minify URLs by converting them from absolute to relative.",
"version": "0.2.4",
"version": "0.2.5",
"homepage": "https://github.com/stevenvachon/relateurl",

@@ -26,3 +26,3 @@ "author": {

"engines": {
"node": ">= 0.6.0"
"node": ">= 0.10"
},

@@ -33,2 +33,5 @@ "scripts": {

},
"files": [
"lib"
],
"keywords": [

@@ -35,0 +38,0 @@ "url",

@@ -46,4 +46,5 @@ # relateurl [![NPM Version](http://badge.fury.io/js/relateurl.svg)](http://badge.fury.io/js/relateurl) [![Build Status](https://secure.travis-ci.org/stevenvachon/relateurl.svg)](http://travis-ci.org/stevenvachon/relateurl)

#### options.output
Type: constant
Type: constant or `String`
Choices: `RelateUrl.ABSOLUTE`,`RelateUrl.PATH_RELATIVE`,`RelateUrl.ROOT_RELATIVE`,`RelateUrl.SHORTEST`
Choices: `"absolute"`,`"pathRelative"`,`"rootRelative"`,`"shortest"`
Default value: `RelateUrl.SHORTEST`

@@ -80,2 +81,8 @@

#### options.removeRootTrailingSlash
Type: `Boolean`
Default value: `true`
Remove trailing slashes from root paths. Example: `http://domain.com/?var` will become `http://domain.com?var` while `http://domain.com/dir/?var` will not be modified.
#### options.schemeRelative

@@ -124,3 +131,3 @@ Type: `Boolean`

1. **Why bother writing/using this?**
To aid in further minifying HTML, mainly for the purpose of faster page loads and SEO.
To aid in further minifying HTML, mainly for the purpose of faster page loads and SEO. It's been integrated into [HTMLMinifier](https://github.com/kangax/html-minifier).

@@ -131,2 +138,3 @@ 2. **Why not just use Node's `url.parse`, `url.resolve` and `path.relative`?**

## Release History
* 0.2.5 added `options.removeRootTrailingSlash`
* 0.2.4 added `options.site`

@@ -140,3 +148,2 @@ * 0.2.3 added browserify npm-script

## Roadmap
* 0.2.5 shorten absolute URLs like `http://domain.com/?var` to `http://domain.com?var`, etc
* 0.2.6 decipher and return invalid input (special cases) to complete test suite

@@ -143,0 +150,0 @@ * 0.3.0 test `options.slashesDenoteHost=false`, add something like `options.externalDirectoryIndexes=[]` for external sites

@@ -16,6 +16,6 @@ module.exports =

{
"absolute": "http://user:pass@www.domain.com/",
"pathRelative": "//user:pass@www.domain.com/",
"rootRelative": "//user:pass@www.domain.com/",
"shortest": "//user:pass@www.domain.com/"
"absolute": "http://user:pass@www.domain.com",
"pathRelative": "//user:pass@www.domain.com",
"rootRelative": "//user:pass@www.domain.com",
"shortest": "//user:pass@www.domain.com"
}

@@ -29,6 +29,6 @@ ]

{
"absolute": "sftp://user:pass@www.domain.com/",
"pathRelative": "sftp://user:pass@www.domain.com/",
"rootRelative": "sftp://user:pass@www.domain.com/",
"shortest": "sftp://user:pass@www.domain.com/"
"absolute": "sftp://user:pass@www.domain.com",
"pathRelative": "sftp://user:pass@www.domain.com",
"rootRelative": "sftp://user:pass@www.domain.com",
"shortest": "sftp://user:pass@www.domain.com"
}

@@ -42,6 +42,6 @@ ]

{
"absolute": "ssh://user:pass@www.domain.com/",
"pathRelative": "ssh://user:pass@www.domain.com/",
"rootRelative": "ssh://user:pass@www.domain.com/",
"shortest": "ssh://user:pass@www.domain.com/"
"absolute": "ssh://user:pass@www.domain.com",
"pathRelative": "ssh://user:pass@www.domain.com",
"rootRelative": "ssh://user:pass@www.domain.com",
"shortest": "ssh://user:pass@www.domain.com"
}

@@ -65,3 +65,3 @@ ]

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -78,3 +78,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -114,3 +114,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -121,3 +121,3 @@ "rootRelative": "/",

{
"absolute": "http://domain.com/",
"absolute": "http://domain.com",
"pathRelative": "",

@@ -134,3 +134,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -141,3 +141,3 @@ "rootRelative": "/",

{
"absolute": "http://domain.com/",
"absolute": "http://domain.com",
"pathRelative": "",

@@ -176,3 +176,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -200,3 +200,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -207,3 +207,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -220,3 +220,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -227,3 +227,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -285,3 +285,3 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/",
"absolute": "http://www.domain.com",
"pathRelative": "",

@@ -292,6 +292,6 @@ "rootRelative": "/",

{
"absolute": "http://www.domain.com/?var1&var2&var3",
"pathRelative": "//www.domain.com/?var1&var2&var3",
"rootRelative": "//www.domain.com/?var1&var2&var3",
"shortest": "//www.domain.com/?var1&var2&var3"
"absolute": "http://www.domain.com?var1&var2&var3",
"pathRelative": "//www.domain.com?var1&var2&var3",
"rootRelative": "//www.domain.com?var1&var2&var3",
"shortest": "//www.domain.com?var1&var2&var3"
}

@@ -305,3 +305,3 @@ ]

{
"absolute": "http://www.domain.com/?var2=asdf",
"absolute": "http://www.domain.com?var2=asdf",
"pathRelative": "?var2=asdf",

@@ -312,6 +312,6 @@ "rootRelative": "/?var2=asdf",

{
"absolute": "http://www.domain.com/?var&var2=asdf&var3",
"pathRelative": "//www.domain.com/?var&var2=asdf&var3",
"rootRelative": "//www.domain.com/?var&var2=asdf&var3",
"shortest": "//www.domain.com/?var&var2=asdf&var3"
"absolute": "http://www.domain.com?var&var2=asdf&var3",
"pathRelative": "//www.domain.com?var&var2=asdf&var3",
"rootRelative": "//www.domain.com?var&var2=asdf&var3",
"shortest": "//www.domain.com?var&var2=asdf&var3"
}

@@ -322,2 +322,24 @@ ]

},
"options.removeRootTrailingSlash":
{
"sites":
[
"http://www.domain.com/"
],
"tests":
[
{
"href": "http://www.domain.com/",
"expected":
[
{
"absolute": "http://www.domain.com/",
"pathRelative": "",
"rootRelative": "/",
"shortest": ""
}
]
}
]
},
"options.schemeRelative":

@@ -336,6 +358,6 @@ {

{
"absolute": "http://www.other.com/",
"pathRelative": "http://www.other.com/",
"rootRelative": "http://www.other.com/",
"shortest": "http://www.other.com/"
"absolute": "http://www.other.com",
"pathRelative": "http://www.other.com",
"rootRelative": "http://www.other.com",
"shortest": "http://www.other.com"
}

@@ -349,6 +371,6 @@ ]

{
"absolute": "https://www.other.com/",
"pathRelative": "https://www.other.com/",
"rootRelative": "https://www.other.com/",
"shortest": "https://www.other.com/"
"absolute": "https://www.other.com",
"pathRelative": "https://www.other.com",
"rootRelative": "https://www.other.com",
"shortest": "https://www.other.com"
}

@@ -355,0 +377,0 @@ ]

@@ -476,2 +476,14 @@ var expect = require("chai").expect;

it("should support options.removeRootTrailingSlash = false", function(done)
{
urlCount += process( data["options.removeRootTrailingSlash"], true,
{
removeRootTrailingSlash: false
});
done();
});
it("should support options.schemeRelative = false", function(done)

@@ -478,0 +490,0 @@ {

Sorry, the diff of this file is too big to display

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