Modules@robinpath/url

@robinpath/url

0.1.0Public

URL parsing, formatting, and query parameter manipulation utilities using the built-in URL API

@robinpath/url

URL parsing, formatting, and query parameter manipulation utilities using the built-in URL API

Category Functions Auth License

Why use this module?

The url module lets you:

  • Parse a URL string into its component parts
  • Format URL component parts into a URL string
  • Resolve a relative URL against a base URL
  • Get the value of a single query parameter from a URL
  • Remove a query parameter from a URL

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/url

Quick Start

No credentials needed — start using it right away:

url.format { protocol: "https:", hostname: "example.com", pathname: "/path" }

Available Functions

FunctionDescription
url.parseParse a URL string into its component parts
url.formatFormat URL component parts into a URL string
url.resolveResolve a relative URL against a base URL
url.getParamGet the value of a single query parameter from a URL
url.setParamSet a query parameter on a URL, replacing any existing value
url.removeParamRemove a query parameter from a URL
url.getParamsGet all query parameters from a URL as a plain object
url.setParamsSet multiple query parameters on a URL at once
url.getHostnameExtract the hostname from a URL
url.getPathnameExtract the pathname from a URL
url.getProtocolExtract the protocol from a URL
url.isValidCheck whether a string is a valid URL
url.encodeEncode a string for safe use in a URL component
url.decodeDecode a URI-encoded string

Examples

Format URL component parts into a URL string

url.format { protocol: "https:", hostname: "example.com", pathname: "/path" }

Resolve a relative URL against a base URL

url.resolve "https://example.com/a/b" "../c"

Get the value of a single query parameter from a URL

url.getParam "https://example.com?foo=bar" "foo"

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/url";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  url.format { protocol: "https:", hostname: "example.com", pathname: "/path" }
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/url
Version0.1.0
LicenseMIT
Unpacked Size5.0 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities