New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

url-query-formatter

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-query-formatter

A utility function to append a query string to a URL.

latest
npmnpm
Version
2.0.3
Version published
Maintainers
0
Created
Source

url-query-formatter

A simple utility function to append a query string to a URL.

Installation

You can install the package using npm:

npm install url-query-formatter

Usage

CommonJS

const { formatter } = require("url-query-formatter");

const url = "https://example.com";
const params = { key1: "value1", key2: "value2" };

const fullUrl = formatter(url, params);
console.log(fullUrl); // Output: https://example.com?key1=value1&key2=value2

ES Modules

import formatter from "url-query-formatter";

const url = "https://example.com";
const params = { key1: "value1", key2: "value2" };

const fullUrl = formatter(url, params);
console.log(fullUrl); // Output: https://example.com?key1=value1&key2=value2

Parameters

formatter(url, params)

  • url (string): The base URL to which the query string will be appended. It should be a valid URL format.
  • params (Object): An object containing key-value pairs that will be converted into query string parameters. Each key in the object represents a query parameter, and the associated value represents the parameter's value.

Author

  • Behzad Bakhshayesh

Keywords

url

FAQs

Package last updated on 29 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts