0.1.3 • Published 3 years ago

rescript-url v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

url bindings for Rescript .

Installation

  1. Install package from npm:

    npm install --save rescript-url

    or

    yarn add rescript-url
  2. Add rescript-url to bs-dependencies section of bsconfig.json:

    "bs-dependencies": [
     "rescript-url"
     ]

Usage

Create URL object.

let myURL = URL.make("https://example.com");
Js.log(myURL);
/* Prints https://example.com */

let otherURL = URL.make("/foo", "https://example.com");
Js.log(otherURL);
/* Prints https://example.com/foo */

Get member in URL object.

URL.make("https://example.com/test#main")
|> URL.hash
|> Js.log
/* Prints #main */

Resove a target URL relative to a base URL.

URL.resolve("https://example.com/", "/foo") /* https://example.com/foo */

Create URLSearchParams object.

/* from String */
let params0 = URLSearchParmas.make("user=abc&query=xyz");

/* from Object */
let params1 = URLSearchParmas.makeWithObject({"user": "abc", "query": [|"first", "second"|]});

/* from Array */
let params2 = URLSearchParmas.makeWithArray([|("user", "abc"), ("query", "first"), ("query", "second")|])
0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago