Skip to content

tacheometry/rbxts-neturl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 NetUrl 🌐

roblox-ts typings for the NetUrl library, a URL and Query string parser, builder, and normalizer for Lua. Some useful links:

Installation

NPM

Run npm i @rbxts/neturl in your project directory.

Usage

To import:

import NetUrl from "@rbxts/neturl";

Below are some usage examples adapted from the NetUrl repository:

URL parser

const u = NetUrl.parse("http://www.example.com/test/?start=10");

print(u.scheme); // http
print(u.host); // www.example.com
print(u.path); // /test/

Querystring parser

const query = NetUrl.parseQuery("a=123&b=456");

print(query); // a=123&b=456
print(query.get("a")); // "123"
print(query.get("b")); // "456"
// Note: replace the type if using brackets in the query string:
const query = NetUrl.parseQuery<string | string[]>("first=abc&a[]=123&a[]=false&b[]=str&c[]=3.5&a[]=last");

print(query); // a[1]=123&a[2]=false&a[3]=last&b[1]=str&c[1]=3.5&first=abc
print(query.get("a")); // [ "3.5" ]