Skip to content

Commit 3d1f35a

Browse files
Update APIs (#20)
* Implement bindings for URL * Add bindings to UrlSearchParams * Update tests * Make next release entry
1 parent 505475b commit 3d1f35a

File tree

8 files changed

+470
-52
lines changed

8 files changed

+470
-52
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
bower install
3636
npm run-script test --if-present
37-
37+
3838
- name: Check formatting
3939
run: |
4040
purs-tidy check src test

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ New features:
1010

1111
Bugfixes:
1212

13+
Other improvements:
14+
15+
## [v7.0.0](https://github.com/purescript-node/purescript-node-url/releases/tag/v7.0.0) - 2023-07-31
16+
17+
Breaking changes:
18+
- Drop support for Legacy API (#20 by @JordanMartinez)
19+
- Drop support for `querystring` bindings (#20 by @JordanMartinez)
20+
- Implement WHATWG URL API bindings (#20 by @JordanMartinez)
21+
22+
New features:
23+
- Implement bindings for `URLSearchParams` (#20 by @JordanMartinez)
24+
25+
Bugfixes:
26+
1327
Other improvements:
1428
- Update CI `node` to `lts/*` (#19 by @JordanMartinez)
1529
- Update CI actions to `v3` (#19 by @JordanMartinez)

bower.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"url": "https://github.com/purescript-node/purescript-node-url.git"
1313
},
1414
"dependencies": {
15-
"purescript-nullable": "^6.0.0"
15+
"purescript-prelude": "^6.0.1",
16+
"purescript-effect": "^4.0.0",
17+
"purescript-foreign": "^7.0.0",
18+
"purescript-nullable": "^6.0.0",
19+
"purescript-tuples": "^7.0.0"
1620
},
1721
"devDependencies": {
1822
"purescript-assert": "^6.0.0"

src/Node/URL.js

+56-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
1-
import url from "url";
2-
import queryString from "querystring";
3-
export { parse, format } from "url";
1+
import url from "node:url";
42

5-
export function resolve(from) {
6-
return to => url.resolve(from, to);
7-
}
3+
export const newImpl = (input) => new url.URL(input);
4+
export const newRelativeImpl = (input, base) => new url.URL(input, base);
5+
export const pathToFileURLImpl = (path) => url.pathToFileURL(path);
6+
export const hashImpl = (u) => u.hash;
7+
export const setHashImpl = (h, u) => {
8+
u.hash = h;
9+
};
10+
export const hostImpl = (url) => url.host;
11+
export const setHostImpl = (val, u) => {
12+
u.host = val;
13+
};
14+
export const hostnameImpl = (u) => u.hostname;
15+
export const setHostnameImpl = (val, u) => {
16+
u.hostname = val;
17+
};
18+
export const uneffectfulHref = (u) => u.href;
19+
export const hrefImpl = (u) => u.href;
20+
export const setHrefImpl = (val, u) => {
21+
u.href = val;
22+
};
23+
export const origin = (u) => u.origin;
24+
export const passwordImpl = (u) => u.password;
25+
export const setPasswordImpl = (val, u) => {
26+
u.password = val;
27+
};
28+
export const pathnameImpl = (u) => u.pathname;
29+
export const setPathnameImpl = (val, u) => {
30+
u.pathname = val;
31+
};
32+
export const portImpl = (u) => u.port;
33+
export const setPortImpl = (val, u) => {
34+
u.port = val;
35+
};
36+
export const protocolImpl = (u) => u.protocol;
37+
export const setProtocolImpl = (val, u) => {
38+
u.protocol = val;
39+
};
40+
export const searchImpl = (u) => u.search;
41+
export const setSearchImpl = (val, u) => {
42+
u.search = val;
43+
};
44+
export const searchParamsImpl = (u) => u.searchParams;
45+
export const usernameImpl = (u) => u.username;
46+
export const setUsernameImpl = (val, u) => {
47+
u.username = val;
48+
};
849

9-
export const parseQueryString = queryString.parse;
10-
export const toQueryString = queryString.stringify;
50+
export const canParseImpl = (input, base) => url.URL.canParse(input, base);
51+
export const domainToAsciiImpl = (domain) => url.domainToASCII(domain);
52+
export const domainToUnicodeImpl = (domain) => url.domainToUnicode(domain);
53+
export const fileURLToPathImpl = (str) => url.fileURLToPath(str);
54+
export const fileURLToPathUrlImpl = (str) => url.fileURLToPath(str);
55+
export const formatImpl = (theUrl) => url.format(theUrl);
56+
export const formatOptsImpl = (theUrl, opts) => url.format(theUrl, opts);
57+
export const pathToFileUrlImpl = (path) => url.pathToFileURL(path);
58+
export const urlToHttpOptionsImpl = (theUrl) => url.urlToHttpOptions(theUrl);

0 commit comments

Comments
 (0)