Validate url in fetch, rework some hints

This commit is contained in:
Jon Staab
2025-08-05 17:23:34 -07:00
parent 2edbd44f64
commit 3b4fe0973d
17 changed files with 64 additions and 36 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@welshman/lib",
"version": "0.4.1",
"version": "0.4.2",
"author": "hodlbod",
"license": "MIT",
"description": "A collection of utilities.",
+3
View File
@@ -1291,6 +1291,9 @@ type FetchOpts = {
* @returns Promise of parsed JSON response
*/
export const fetchJson = async (url: string, opts: FetchOpts = {}) => {
// Make sure the url is valid, this will throw if not
url = String(new URL(url))
if (!opts.headers) {
opts.headers = {}
}