Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
construct-url
Advanced tools
Readme
A lightweight NPM module to construct URLs including query parameters, path, protocol, domain and hash.
Installation using NPM:
$ npm i construct-url --save
Example usage:
const constructURL = require("construct-url");
// returns "https://example.com/page/details?option_a=test&option_b=test_two#main"
constructURL("http://example.com/", {
queryParams: {
option_a: "TEST",
OPTION_B: "test_two"
},
path: "/page/details",
lowercase: true,
protocol: "https",
hash: "main"
});
constructUrl(baseUrl, options);
The base URL is the domain for the constructed URL and which all query parameters, the path and the hash is appended to.
Query parameters should be a object passed in. Each key and value in the object will be appended to the URL as a query parameter. The key will be used as the query parameter and the value as the query value.
For example a query parameter object containing a key of "a" and a corresponding value of "b", would result in a query string of "?a=b".
Path parameter will be added to the URL as a path. The path parameter will avoid duplicate "/" in the path, by removing the last character of the base URL if it is a "/" and the first character of the path if it is a slash "/".
The hash parameter will be used to add a hash symbol and the value to the end of a URL. For example, if a hash value of "main" is provided, the constructed URL will end in "#main".
If the lowercase parameter has a value of true
, the path, hash and query parameters will all be converted to lowercase.
If the protocol attribute is equal to "https" or "http", the constructed URL will start with the relevant protocol. If the base URL provided already has a different protocol, the protocol will be replaced. If the protocol attribute is equal to "none", the constructed URL will have no protocol, even if the base URL had a protocol.
FAQs
A lightweight library to construct URLs including query parameters, path, protocol, domain and hash.
The npm package construct-url receives a total of 0 weekly downloads. As such, construct-url popularity was classified as not popular.
We found that construct-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.