You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@zthun/webigail-url

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zthun/webigail-url

Url parsing and building.

4.0.4
latest
Source
npmnpm
Version published
Weekly downloads
14
-60%
Maintainers
1
Weekly downloads
 
Created
Source

Webigail URL

It's easy to make mistakes when making REST invocations and public API calls. Webigail solves this by using the builder pattern to construct a full URL given different parts of a URI.

Build Status

CircleCI

Usage

Webigail is built in TypeScript and it exports both ESM and CJS modules.

# NPM
npm install @zthun/webigail-url
# Yarn
yarn add @zthun/webigail-url
import { ZUrlBuilder } from "@zthun/webigail-url";

const url = new ZUrlBuilder()
  .protocol("https")
  .hostname("zthunworks.com")
  .subdomain("webigail")
  .build();

// Outputs https://webigail.zthunworks.com
console.log(url);

There are also some utility functions for common use cases.

import { ZUrlBuilder } from "@zthun/webigail-url";

// Note: Browser only unless you're using jsdom in node.  Outputs the current
// browser location with /api appended to it.
const locationUrl = new ZUrlBuilder().location(location).path("/api").build();
console.log(url);

// Url for a persons gravatar if one exists.
const avatar = new ZUrlBuilder()
  .gravatar(md5("john-doe@gmail.com"), 256)
  .build();
console.log(avatar);

// Outputs the existing pieces of the url.
const existingInfo = new ZUrlBuilder()
  .parse("https://webigail.zthunworks.com/api/path?filter=hello")
  .info();
console.log(existingInfo);

Data URLs

Webigail also supports building and parsing data urls as well.

import { ZDataUrlBuilder, ZMimeTypeApplication } from "@zthun/webigail-url";

const raw = require("my-data.json");
const mimeType = ZMimeTypeApplication.JSON;
const url = new ZDataUrlBuilder()
  .mimeType(mimeType)
  .buffer(Buffer.from(raw))
  .encode("base64")
  .build();
console.log(url);

FAQs

Package last updated on 22 Jun 2025

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