mirror of
https://github.com/outline/outline.git
synced 2026-11-22 14:01:41 +03:00
Update mock for request-filtering-agent to validate protocols
Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>
This commit is contained in:
1 parent
9dbb84f966
commit
52de8f9588
1 file changed
+7
@@ -9,6 +9,13 @@ function useAgent(url, options = {}) {
|
||||
const parsedUrl = new URL(url);
|
||||
const isHttps = parsedUrl.protocol === "https:";
|
||||
|
||||
// Validate that the URL protocol is supported
|
||||
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
||||
throw new TypeError(
|
||||
`Protocol "${parsedUrl.protocol}" not supported. Expected "http:" or "https:"`
|
||||
);
|
||||
}
|
||||
|
||||
// Create a basic agent based on the protocol
|
||||
const Agent = isHttps ? https.Agent : http.Agent;
|
||||
|
||||
|
||||
Reference in new issue
Block a user