Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update APIs #20

Merged
merged 17 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be hrefPure? I think that’s a more common naming convention than “uneffectful”

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that name better. I'll send a PR.

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