Skip to content

Commit b917378

Browse files
authored
Merge pull request #32 from Clever/INFRANG-6523
[INFRANG-6523] fix: update template_external_url to replace hyphens with underscores
2 parents 45cc4f8 + 3c7c960 commit b917378

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

__tests__/discovery.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const pairs = {
1818
SERVICE_MISSING_PROTO_AND_HOST_FOOBAR_PORT: "8000",
1919
EXTERNAL_URL_CLEVER_COM: "https://clever.com:443",
2020
EXTERNAL_URL_API_CLEVER_COM: "https://api.clever.com:443",
21+
EXTERNAL_URL_DIAGNOSTICS_APP_CLEVER_COM: "https://diagnostics-app.clever.com:443",
2122
};
2223

2324
describe("discovery", () => {
@@ -110,6 +111,13 @@ describe("discovery", () => {
110111
assert.equal(ex_disc.host(), "api.clever.com");
111112
assert.equal(ex_disc.host_port(), "api.clever.com:443");
112113
});
114+
it("test external url with hyphens", () => {
115+
const ex_disc = external("diagnostics-app.clever.com");
116+
assert.equal(ex_disc.url(), "https://diagnostics-app.clever.com:443");
117+
assert.equal(ex_disc.proto_host(), "https://diagnostics-app.clever.com");
118+
assert.equal(ex_disc.host(), "diagnostics-app.clever.com");
119+
assert.equal(ex_disc.host_port(), "diagnostics-app.clever.com:443");
120+
});
113121
return it("test expect error on missing two vars", () => {
114122
const disc = discovery("missing-proto-and-host", "foobar");
115123
assert.equal(disc.port(), "8000");

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function template_service(service_name: string, interface_name: string, value: s
33
}
44

55
function template_external_url(input_url: string) {
6-
return `EXTERNAL_URL_${input_url.toUpperCase().replace(/\./g, "_")}`;
6+
return `EXTERNAL_URL_${input_url.toUpperCase().replace(/\./g, "_").replace(/-/g, "_")}`;
77
}
88

99
function get_var(env_var: string) {

0 commit comments

Comments
 (0)