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

build-url-ts

Package Overview
Dependencies
Maintainers
1
Versions
305
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-url-ts - npm Package Compare versions

Comparing version 5.0.4 to 5.0.5

66

dist/build-url.js

@@ -1,5 +0,56 @@

Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
function appendPath(path, builtUrl, lowerCase) {
if (builtUrl[builtUrl.length - 1] === "/") {
builtUrl = builtUrl.slice(0, -1);
}
var pathString = String(path).trim();
if (lowerCase) {
pathString = pathString.toLowerCase();
}
if (pathString.indexOf("/") === 0) {
builtUrl += pathString;
}
else {
builtUrl += "/" + pathString;
}
return builtUrl;
}
function buildHash(hash, lowerCase) {
var hashString = "#" + String(hash).trim();
return lowerCase ? hashString.toLowerCase() : hashString;
}
function buildQueryString(queryParams, lowerCase, disableCSV) {
var queryString = [];
var _loop_1 = function (key) {
if (Object.prototype.hasOwnProperty.call(queryParams, key) &&
queryParams[key] !== void 0) {
var param_1;
if (disableCSV &&
Array.isArray(queryParams[key]) &&
queryParams[key].length) {
queryParams[key].forEach(function (v) {
param_1 = v !== 0 ? v || "" : 0;
queryString.push(key + "=" + encodeURIComponent(String(param_1).trim()));
});
}
else {
if (lowerCase) {
param_1 = String(queryParams[key]).toLowerCase() || "";
}
else {
param_1 = queryParams[key] !== 0 ? queryParams[key] || "" : 0;
}
queryString.push(key + "=" + encodeURIComponent(String(param_1).trim()));
}
}
};
for (var key in queryParams) {
_loop_1(key);
}
return "?" + queryString.join("&");
}
function buildUrl(url, options) {
let builtUrl;
var builtUrl;
if (url === null) {

@@ -16,13 +67,14 @@ builtUrl = "";

if (options === null || options === void 0 ? void 0 : options.path) {
builtUrl = utils_1.appendPath(options.path, builtUrl, options.lowerCase);
builtUrl = appendPath(options.path, builtUrl, options.lowerCase);
}
if (options === null || options === void 0 ? void 0 : options.queryParams) {
builtUrl += utils_1.buildQueryString(options.queryParams, options.lowerCase, options.disableCSV);
builtUrl += buildQueryString(options.queryParams, options.lowerCase, options.disableCSV);
}
if (options === null || options === void 0 ? void 0 : options.hash) {
builtUrl += utils_1.buildHash(options.hash, options.lowerCase);
builtUrl += buildHash(options.hash, options.lowerCase);
}
return builtUrl;
}
exports.default = buildUrl;
export default buildUrl;
//# sourceMappingURL=build-url.js.map

2

dist/src/build-url.d.ts

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

declare type IQueryParams = Record<string, string | number | string[] | (string | number)[]>;
import { IQueryParams } from "./utils/build-query-string";
interface IUrlOptions {

@@ -3,0 +3,0 @@ path?: string | number;

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

declare type IQueryParams = Record<string, string | number | string[] | (string | number)[]>;
export declare type IQueryParams = Record<string, null | undefined | string | number | string[] | (string | number)[]>;
declare function buildQueryString(queryParams: IQueryParams, lowerCase?: boolean, disableCSV?: boolean): string;
export default buildQueryString;
//# sourceMappingURL=build-query-string.d.ts.map
{
"name": "build-url-ts",
"version": "5.0.4",
"version": "5.0.5",
"description": "A small library that builds a URL given its components",

@@ -5,0 +5,0 @@ "main": "./dist/build-url.js",

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