-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from AikidoSec/fix-legacy-url
Fix legacy url object in http request
- Loading branch information
Showing
8 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as t from "tap"; | ||
import { isOptionsObject } from "./isOptionsObject"; | ||
|
||
t.test("it works with objects", async (t) => { | ||
t.equal(isOptionsObject({}), true); | ||
t.equal(isOptionsObject({ protocol: "https:" }), true); | ||
t.equal(isOptionsObject({ hostname: "localhost" }), true); | ||
t.equal(isOptionsObject({ port: 4000 }), true); | ||
t.equal(isOptionsObject({ path: "/test" }), true); | ||
t.equal( | ||
isOptionsObject({ | ||
protocol: "https:", | ||
hostname: "localhost", | ||
port: 4000, | ||
path: "/test", | ||
}), | ||
true | ||
); | ||
}); | ||
|
||
t.test("it works with non-objects", async (t) => { | ||
t.equal(isOptionsObject("test"), false); | ||
t.equal(isOptionsObject(1), false); | ||
t.equal(isOptionsObject([]), false); | ||
t.equal(isOptionsObject(null), false); | ||
t.equal(isOptionsObject(undefined), false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Check if the argument is treated as an options object by Node.js. | ||
* For checking if the argument can be used as options for a outgoing HTTP request. | ||
*/ | ||
export function isOptionsObject(arg: any): arg is { [key: string]: unknown } { | ||
return typeof arg === "object" && !Array.isArray(arg) && arg !== null; | ||
} |