Skip to content

Commit

Permalink
Merge pull request #32 from Clever/INFRANG-6523
Browse files Browse the repository at this point in the history
[INFRANG-6523] fix: update template_external_url to replace hyphens with underscores
  • Loading branch information
andruwm authored Jan 2, 2025
2 parents 45cc4f8 + 3c7c960 commit b917378
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions __tests__/discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const pairs = {
SERVICE_MISSING_PROTO_AND_HOST_FOOBAR_PORT: "8000",
EXTERNAL_URL_CLEVER_COM: "https://clever.com:443",
EXTERNAL_URL_API_CLEVER_COM: "https://api.clever.com:443",
EXTERNAL_URL_DIAGNOSTICS_APP_CLEVER_COM: "https://diagnostics-app.clever.com:443",
};

describe("discovery", () => {
Expand Down Expand Up @@ -110,6 +111,13 @@ describe("discovery", () => {
assert.equal(ex_disc.host(), "api.clever.com");
assert.equal(ex_disc.host_port(), "api.clever.com:443");
});
it("test external url with hyphens", () => {
const ex_disc = external("diagnostics-app.clever.com");
assert.equal(ex_disc.url(), "https://diagnostics-app.clever.com:443");
assert.equal(ex_disc.proto_host(), "https://diagnostics-app.clever.com");
assert.equal(ex_disc.host(), "diagnostics-app.clever.com");
assert.equal(ex_disc.host_port(), "diagnostics-app.clever.com:443");
});
return it("test expect error on missing two vars", () => {
const disc = discovery("missing-proto-and-host", "foobar");
assert.equal(disc.port(), "8000");
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function template_service(service_name: string, interface_name: string, value: s
}

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

function get_var(env_var: string) {
Expand Down

0 comments on commit b917378

Please sign in to comment.