Skip to content

Commit db1a4ac

Browse files
feat(env): Support trailing slashes on ARCJET_BASE_URL (#5035)
Closes #4984 Alternative to #4981 I prefer less moving parts and am hesitant to normalize the environment variable the user gives us (instead deferring that to Connect RPC). Given that, I'd rather we enumerate all the URLs that we support with and without a trailing slash.
1 parent 2dc0654 commit db1a4ac

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

env/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ const baseUrlAllowed = [
117117
"https://fly.decide.arcjet.com",
118118
"https://fly.decide.arcjettest.com",
119119
"https://decide.arcjet.orb.local",
120+
// Allow trailing slashes
121+
"https://decide.arcjet.com/",
122+
"https://decide.arcjettest.com/",
123+
"https://fly.decide.arcjet.com/",
124+
"https://fly.decide.arcjettest.com/",
125+
"https://decide.arcjet.orb.local/",
120126
];
121127

122128
/**

env/test/env.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,38 @@ describe("env", () => {
102102
env.baseUrl({ FLY_APP_NAME: "foobar" }),
103103
"https://fly.decide.arcjet.com",
104104
);
105+
106+
// Trailing slash.
107+
assert.equal(
108+
env.baseUrl({
109+
ARCJET_BASE_URL: "https://decide.arcjet.com/",
110+
}),
111+
"https://decide.arcjet.com/",
112+
);
113+
assert.equal(
114+
env.baseUrl({
115+
ARCJET_BASE_URL: "https://decide.arcjettest.com/",
116+
}),
117+
"https://decide.arcjettest.com/",
118+
);
119+
assert.equal(
120+
env.baseUrl({
121+
ARCJET_BASE_URL: "https://fly.decide.arcjet.com/",
122+
}),
123+
"https://fly.decide.arcjet.com/",
124+
);
125+
assert.equal(
126+
env.baseUrl({
127+
ARCJET_BASE_URL: "https://fly.decide.arcjettest.com/",
128+
}),
129+
"https://fly.decide.arcjettest.com/",
130+
);
131+
assert.equal(
132+
env.baseUrl({
133+
ARCJET_BASE_URL: "https://decide.arcjet.orb.local/",
134+
}),
135+
"https://decide.arcjet.orb.local/",
136+
);
105137
});
106138

107139
test("apiKey", () => {

0 commit comments

Comments
 (0)