This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Invalid proxy settings should be handled and not crash (#11)
- Loading branch information
1 parent
b86d038
commit 09896a2
Showing
4 changed files
with
85 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,6 @@ node_js: | |
- 9 | ||
- 8 | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
install: | ||
- npm install | ||
script: | ||
|
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,50 @@ | ||
import { expect } from "chai"; | ||
import { parseWindowsProxySetting } from "./proxy"; | ||
describe("proxy", () => { | ||
describe("parseWindowsProxySetting", () => { | ||
it("should return null if null or undefined", () => { | ||
expect(parseWindowsProxySetting(null)).to.be.null; | ||
expect(parseWindowsProxySetting(undefined)).to.be.null; | ||
}); | ||
|
||
it("should return same url for http and https if just a url is provided", () => { | ||
const value = parseWindowsProxySetting("http://localhost:8888"); | ||
expect(value).not.to.be.null; | ||
expect(value.http.host).to.eql("localhost"); | ||
expect(value.http.port).to.eql("8888"); | ||
expect(value.https.host).to.eql("localhost"); | ||
expect(value.https.port).to.eql("8888"); | ||
}); | ||
|
||
it("should coresponding http and https urls", () => { | ||
const value = parseWindowsProxySetting("http=http://localhost:8888;https=http://localhost:9999"); | ||
expect(value).not.to.be.null; | ||
expect(value.http.host).to.eql("localhost"); | ||
expect(value.http.port).to.eql("8888"); | ||
expect(value.https.host).to.eql("localhost"); | ||
expect(value.https.port).to.eql("9999"); | ||
}); | ||
|
||
it("should assign https automatically if missing but http provided", () => { | ||
const value = parseWindowsProxySetting("http=http://localhost:8888"); | ||
expect(value).not.to.be.null; | ||
expect(value.http.host).to.eql("localhost"); | ||
expect(value.http.port).to.eql("8888"); | ||
expect(value.https.host).to.eql("localhost"); | ||
expect(value.https.port).to.eql("8888"); | ||
}); | ||
|
||
it("should assign http automatically if missing but https provided", () => { | ||
const value = parseWindowsProxySetting("https=http://localhost:8888"); | ||
expect(value).not.to.be.null; | ||
expect(value.http.host).to.eql("localhost"); | ||
expect(value.http.port).to.eql("8888"); | ||
expect(value.https.host).to.eql("localhost"); | ||
expect(value.https.port).to.eql("8888"); | ||
}); | ||
|
||
it("should return null if invalid url is provided", () => { | ||
expect(parseWindowsProxySetting("invalid-url")).to.be.null; | ||
}); | ||
}); | ||
}); |
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