Skip to content

Commit

Permalink
Update APIs (#20)
Browse files Browse the repository at this point in the history
* Implement bindings for URL

* Add bindings to UrlSearchParams

* Update tests

* Make next release entry
  • Loading branch information
JordanMartinez authored Aug 1, 2023
1 parent 505475b commit 3d1f35a
Show file tree
Hide file tree
Showing 8 changed files with 470 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
bower install
npm run-script test --if-present
- name: Check formatting
run: |
purs-tidy check src test
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ New features:

Bugfixes:

Other improvements:

## [v7.0.0](https://github.com/purescript-node/purescript-node-url/releases/tag/v7.0.0) - 2023-07-31

Breaking changes:
- Drop support for Legacy API (#20 by @JordanMartinez)
- Drop support for `querystring` bindings (#20 by @JordanMartinez)
- Implement WHATWG URL API bindings (#20 by @JordanMartinez)

New features:
- Implement bindings for `URLSearchParams` (#20 by @JordanMartinez)

Bugfixes:

Other improvements:
- Update CI `node` to `lts/*` (#19 by @JordanMartinez)
- Update CI actions to `v3` (#19 by @JordanMartinez)
Expand Down
6 changes: 5 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"url": "https://github.com/purescript-node/purescript-node-url.git"
},
"dependencies": {
"purescript-nullable": "^6.0.0"
"purescript-prelude": "^6.0.1",
"purescript-effect": "^4.0.0",
"purescript-foreign": "^7.0.0",
"purescript-nullable": "^6.0.0",
"purescript-tuples": "^7.0.0"
},
"devDependencies": {
"purescript-assert": "^6.0.0"
Expand Down
64 changes: 56 additions & 8 deletions src/Node/URL.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,58 @@
import url from "url";
import queryString from "querystring";
export { parse, format } from "url";
import url from "node:url";

export function resolve(from) {
return to => url.resolve(from, to);
}
export const newImpl = (input) => new url.URL(input);
export const newRelativeImpl = (input, base) => new url.URL(input, base);
export const pathToFileURLImpl = (path) => url.pathToFileURL(path);
export const hashImpl = (u) => u.hash;
export const setHashImpl = (h, u) => {
u.hash = h;
};
export const hostImpl = (url) => url.host;
export const setHostImpl = (val, u) => {
u.host = val;
};
export const hostnameImpl = (u) => u.hostname;
export const setHostnameImpl = (val, u) => {
u.hostname = val;
};
export const uneffectfulHref = (u) => u.href;
export const hrefImpl = (u) => u.href;
export const setHrefImpl = (val, u) => {
u.href = val;
};
export const origin = (u) => u.origin;
export const passwordImpl = (u) => u.password;
export const setPasswordImpl = (val, u) => {
u.password = val;
};
export const pathnameImpl = (u) => u.pathname;
export const setPathnameImpl = (val, u) => {
u.pathname = val;
};
export const portImpl = (u) => u.port;
export const setPortImpl = (val, u) => {
u.port = val;
};
export const protocolImpl = (u) => u.protocol;
export const setProtocolImpl = (val, u) => {
u.protocol = val;
};
export const searchImpl = (u) => u.search;
export const setSearchImpl = (val, u) => {
u.search = val;
};
export const searchParamsImpl = (u) => u.searchParams;
export const usernameImpl = (u) => u.username;
export const setUsernameImpl = (val, u) => {
u.username = val;
};

export const parseQueryString = queryString.parse;
export const toQueryString = queryString.stringify;
export const canParseImpl = (input, base) => url.URL.canParse(input, base);
export const domainToAsciiImpl = (domain) => url.domainToASCII(domain);
export const domainToUnicodeImpl = (domain) => url.domainToUnicode(domain);
export const fileURLToPathImpl = (str) => url.fileURLToPath(str);
export const fileURLToPathUrlImpl = (str) => url.fileURLToPath(str);
export const formatImpl = (theUrl) => url.format(theUrl);
export const formatOptsImpl = (theUrl, opts) => url.format(theUrl, opts);
export const pathToFileUrlImpl = (path) => url.pathToFileURL(path);
export const urlToHttpOptionsImpl = (theUrl) => url.urlToHttpOptions(theUrl);
Loading

0 comments on commit 3d1f35a

Please sign in to comment.