Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "urlconcat", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Concats paths in an url, places slashes where necessary.", | ||
@@ -8,3 +8,3 @@ "main": "urlconcat.js", | ||
"test": "jshint urlconcat.js & node ./test/urlconcatTest.js", | ||
"release": "uglifyjs urlconcat.js > urlconcat.min.js & npm-release patch" | ||
"release": "uglifyjs urlconcat.js > urlconcat.min.js & npm-release patch -m Release [ci skip]" | ||
}, | ||
@@ -29,7 +29,7 @@ "repository": { | ||
"buster": "^0.7.18", | ||
"jshint": "^2.6.3", | ||
"npm-release": "0.0.4-3", | ||
"uglify-js": "^2.4.16" | ||
"jshint": "^2.9.4", | ||
"npm-release": "1.0.0", | ||
"uglify-js": "^2.7.4" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -12,2 +12,3 @@ # urlconcat | ||
### CommonJS | ||
```javascript | ||
@@ -17,1 +18,16 @@ var urlconcat = require('urlconcat'); | ||
``` | ||
### ES2015 | ||
```javascript | ||
import urlconcat from 'urlconcat'; | ||
urlconcat.concat('http://localhost:8080/', 'search', 'something'); // 'http://localhost:8080/search/something' | ||
``` | ||
or | ||
```javascript | ||
import { concat } from 'urlconcat'; | ||
concat('http://localhost:8080/', 'search', 'something'); // 'http://localhost:8080/search/something' | ||
``` | ||
(function() { | ||
'use strict'; | ||
var trailingSlashIfNecessary = function(url) { | ||
return url.substr(-1) !== '/' ? url + '/' : url; | ||
var trailingSlashIfNecessary = function(urlPart, nextUrlPart) { | ||
if (nextUrlPart.substr(0, 1) === '?') { | ||
return urlPart; | ||
} | ||
return urlPart.substr(-1) !== '/' ? urlPart + '/' : urlPart; | ||
}; | ||
@@ -12,5 +15,6 @@ | ||
for (var i = 0; i < args.length - 1; i++) { | ||
concatted += trailingSlashIfNecessary(args[i]); | ||
concatted += trailingSlashIfNecessary(args[i], args[i+1]); | ||
} | ||
return concatted += args[args.length - 1]; | ||
concatted += args[args.length - 1]; | ||
return concatted.replace(/([^:]\/)\/+/g, "$1"); | ||
}; | ||
@@ -17,0 +21,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var trailingSlashIfNecessary=function(url){return url.substr(-1)!=="/"?url+"/":url};var urlconcat=function(){var args=arguments;var concatted="";for(var i=0;i<args.length-1;i++){concatted+=trailingSlashIfNecessary(args[i])}return concatted+=args[args.length-1]};if(typeof define==="function"&&define.amd){define(function(){return{concat:urlconcat}})}else if(typeof module!=="undefined"&&module.exports){module.exports.concat=urlconcat}else{this.urlconcat=urlconcat}}).call(this); | ||
(function(){"use strict";var trailingSlashIfNecessary=function(urlPart,nextUrlPart){if(nextUrlPart.substr(0,1)==="?"){return urlPart}return urlPart.substr(-1)!=="/"?urlPart+"/":urlPart};var urlconcat=function(){var args=arguments;var concatted="";for(var i=0;i<args.length-1;i++){concatted+=trailingSlashIfNecessary(args[i],args[i+1])}concatted+=args[args.length-1];return concatted.replace(/([^:]\/)\/+/g,"$1")};if(typeof define==="function"&&define.amd){define(function(){return{concat:urlconcat}})}else if(typeof module!=="undefined"&&module.exports){module.exports.concat=urlconcat}else{this.urlconcat=urlconcat}}).call(this); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4066
6
34
32