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

@livechat/url-utils

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livechat/url-utils - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

es/getPathname.js

15

es/buildQueryString.js

@@ -1,6 +0,11 @@

import compose from 'lodash/fp/compose';
import join from 'lodash/fp/join';
import map from 'lodash/fp/map';
import toPairs from 'lodash/fp/toPairs';
var toPairs = function toPairs(obj) {
return Object.keys(obj).map(function (key) {
return [key, obj[key]];
});
};
export default /*#__PURE__*/compose( /*#__PURE__*/join('&'), /*#__PURE__*/map( /*#__PURE__*/compose( /*#__PURE__*/join('='), /*#__PURE__*/map(encodeURIComponent))), toPairs);
export default (function (obj) {
return toPairs(obj).map(function (pair) {
return pair.map(encodeURIComponent).join('=');
}).join('&');
});

@@ -1,6 +0,15 @@

import compose from 'lodash/fp/compose';
import fromPairs from 'lodash/fp/fromPairs';
import map from 'lodash/fp/map';
import split from 'lodash/fp/split';
var fromPairs = function fromPairs(pairs) {
return pairs.reduce(function (obj, _ref) {
var key = _ref[0],
value = _ref[1];
export default /*#__PURE__*/compose(fromPairs, /*#__PURE__*/map( /*#__PURE__*/compose( /*#__PURE__*/map(decodeURIComponent), /*#__PURE__*/split('='))), /*#__PURE__*/split('&'));
obj[key] = value;
return obj;
}, {});
};
export default (function (query) {
return fromPairs(query.split('&').map(function (pair) {
return pair.split('=').map(decodeURIComponent);
}));
});
import { decodeQueryString, getSearch, trimSearch } from '.';
export default (function (name, url) {
return decodeQueryString(trimSearch(getSearch(url)))[name];
var search = trimSearch(getSearch(url));
return decodeQueryString(search ? search : url)[name];
});

@@ -1,4 +0,5 @@

var preSearchRegexp = /.+\?/;
var preSearchRegexp = /.*\?(.+)/;
export default (function (url) {
return url.replace(preSearchRegexp, '?');
var match = url.match(preSearchRegexp);
return match ? '?' + match[1] : '';
});

@@ -5,4 +5,5 @@ export { default as buildQueryString } from './buildQueryString';

export { default as getQueryParam } from './getQueryParam';
export { default as getPathname } from './getPathname';
export { default as getSearch } from './getSearch';
export { default as removeProtocol } from './removeProtocol';
export { default as trimSearch } from './trimSearch';

@@ -0,3 +1,4 @@

var protocolRegexp = /^((http(s)?\:)?\/\/)/;
export default (function (url) {
return url.replace('http://', '').replace('https://', '').replace('//', '');
return url.replace(protocolRegexp, '');
});
'use strict';
exports.__esModule = true;
var toPairs = function toPairs(obj) {
return Object.keys(obj).map(function (key) {
return [key, obj[key]];
});
};
var _compose = /*#__PURE__*/require('lodash/fp/compose');
var _compose2 = /*#__PURE__*/_interopRequireDefault(_compose);
var _join = /*#__PURE__*/require('lodash/fp/join');
var _join2 = /*#__PURE__*/_interopRequireDefault(_join);
var _map = /*#__PURE__*/require('lodash/fp/map');
var _map2 = /*#__PURE__*/_interopRequireDefault(_map);
var _toPairs = /*#__PURE__*/require('lodash/fp/toPairs');
var _toPairs2 = /*#__PURE__*/_interopRequireDefault(_toPairs);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = /*#__PURE__*/(0, _compose2.default)( /*#__PURE__*/(0, _join2.default)('&'), /*#__PURE__*/(0, _map2.default)( /*#__PURE__*/(0, _compose2.default)( /*#__PURE__*/(0, _join2.default)('='), /*#__PURE__*/(0, _map2.default)(encodeURIComponent))), _toPairs2.default);
exports.default = function (obj) {
return toPairs(obj).map(function (pair) {
return pair.map(encodeURIComponent).join('=');
}).join('&');
};
'use strict';
exports.__esModule = true;
var fromPairs = function fromPairs(pairs) {
return pairs.reduce(function (obj, _ref) {
var key = _ref[0],
value = _ref[1];
var _compose = /*#__PURE__*/require('lodash/fp/compose');
obj[key] = value;
return obj;
}, {});
};
var _compose2 = /*#__PURE__*/_interopRequireDefault(_compose);
var _fromPairs = /*#__PURE__*/require('lodash/fp/fromPairs');
var _fromPairs2 = /*#__PURE__*/_interopRequireDefault(_fromPairs);
var _map = /*#__PURE__*/require('lodash/fp/map');
var _map2 = /*#__PURE__*/_interopRequireDefault(_map);
var _split = /*#__PURE__*/require('lodash/fp/split');
var _split2 = /*#__PURE__*/_interopRequireDefault(_split);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = /*#__PURE__*/(0, _compose2.default)(_fromPairs2.default, /*#__PURE__*/(0, _map2.default)( /*#__PURE__*/(0, _compose2.default)( /*#__PURE__*/(0, _map2.default)(decodeURIComponent), /*#__PURE__*/(0, _split2.default)('='))), /*#__PURE__*/(0, _split2.default)('&'));
exports.default = function (query) {
return fromPairs(query.split('&').map(function (pair) {
return pair.split('=').map(decodeURIComponent);
}));
};

@@ -8,3 +8,4 @@ 'use strict';

exports.default = function (name, url) {
return (0, _.decodeQueryString)((0, _.trimSearch)((0, _.getSearch)(url)))[name];
var search = (0, _.trimSearch)((0, _.getSearch)(url));
return (0, _.decodeQueryString)(search ? search : url)[name];
};
'use strict';
exports.__esModule = true;
var preSearchRegexp = /.+\?/;
var preSearchRegexp = /.*\?(.+)/;
exports.default = function (url) {
return url.replace(preSearchRegexp, '?');
var match = url.match(preSearchRegexp);
return match ? '?' + match[1] : '';
};

@@ -41,2 +41,11 @@ 'use strict';

var _getPathname = /*#__PURE__*/require('./getPathname');
Object.defineProperty(exports, 'getPathname', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_getPathname).default;
}
});
var _getSearch = /*#__PURE__*/require('./getSearch');

@@ -43,0 +52,0 @@

'use strict';
exports.__esModule = true;
var protocolRegexp = /^((http(s)?\:)?\/\/)/;
exports.default = function (url) {
return url.replace('http://', '').replace('https://', '').replace('//', '');
return url.replace(protocolRegexp, '');
};
{
"name": "@livechat/url-utils",
"version": "0.0.1",
"version": "0.1.0",
"description": "URL utility functions",

@@ -13,13 +13,4 @@ "contributors": [

"jsnext:main": "es/index.js",
"files": [
"lib",
"es"
],
"keywords": [
"url",
"utils"
],
"dependencies": {
"lodash": "^4.17.4"
},
"files": ["lib", "es"],
"keywords": ["url", "utils"],
"devDependencies": {

@@ -37,3 +28,3 @@ "babel-cli": "^6.24.1",

"rimraf": "^2.6.1",
"rollup": "^0.50.0",
"rollup": "^0.51.7",
"rollup-plugin-babel": "^2.7.1",

@@ -47,6 +38,10 @@ "rollup-plugin-commonjs": "^8.2.1",

"prebuild": "rimraf es lib dist",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -i src/index.js -o dist/url-utils.min.js",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/url-utils.js",
"build:cjs": "cross-env BABEL_ENV=cjs babel src --ignore *.test.js --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --ignore *.test.js --out-dir es",
"build:umd:min":
"cross-env BABEL_ENV=es NODE_ENV=production rollup -c -i src/index.js -o dist/url-utils.min.js",
"build:umd":
"cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/url-utils.js",
"build:cjs":
"cross-env BABEL_ENV=cjs babel src --ignore *.test.js --out-dir lib",
"build:es":
"cross-env BABEL_ENV=es babel src --ignore *.test.js --out-dir es",
"build": "run-p build:**",

@@ -53,0 +48,0 @@ "watch": "npm run build:es -- --watch",

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