fix potential url parser crash
This commit is contained in:
parent
81b8e7581a
commit
c9168d4e28
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@squeebot/core",
|
"name": "@squeebot/core",
|
||||||
"version": "3.3.6",
|
"version": "3.3.7",
|
||||||
"description": "Squeebot v3 core for the execution environment",
|
"description": "Squeebot v3 core for the execution environment",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
@ -18,7 +18,13 @@ export function httpGET(
|
|||||||
saveTo?: string,
|
saveTo?: string,
|
||||||
lback?: number
|
lback?: number
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const parsed = new URL(link);
|
let parsed: URL;
|
||||||
|
try {
|
||||||
|
parsed = new URL(link);
|
||||||
|
} catch (e: any) {
|
||||||
|
return Promise.reject(e);
|
||||||
|
}
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: '*/*',
|
Accept: '*/*',
|
||||||
@ -113,8 +119,15 @@ export function httpPOST(
|
|||||||
headers: any = {},
|
headers: any = {},
|
||||||
data: any
|
data: any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const parsed = new URL(link);
|
let parsed: URL;
|
||||||
let postData: string | URLSearchParams = new URLSearchParams(data);
|
let postData: string | URLSearchParams;
|
||||||
|
|
||||||
|
try {
|
||||||
|
parsed = new URL(link);
|
||||||
|
postData = new URLSearchParams(data);
|
||||||
|
} catch(e: any) {
|
||||||
|
return Promise.reject(e);
|
||||||
|
}
|
||||||
|
|
||||||
const opts: RequestOptions = {
|
const opts: RequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
Reference in New Issue
Block a user