Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ it("should return no headers", async () => {
await expect(getHeaders("", "command", logger)).resolves.toStrictEqual({})
await expect(getHeaders("localhost", " ", logger)).resolves.toStrictEqual({})
await expect(getHeaders(" ", "command", logger)).resolves.toStrictEqual({})
await expect(getHeaders("localhost", "printf ''", logger)).resolves.toStrictEqual({})
})

it("should return headers", async () => {
Expand All @@ -43,7 +44,6 @@ it("should error on malformed or empty lines", async () => {
await expect(getHeaders("localhost", "printf ' =foo'", logger)).rejects.toMatch(/Malformed/)
await expect(getHeaders("localhost", "printf 'foo =bar'", logger)).rejects.toMatch(/Malformed/)
await expect(getHeaders("localhost", "printf 'foo foo=bar'", logger)).rejects.toMatch(/Malformed/)
await expect(getHeaders("localhost", "printf ''", logger)).rejects.toMatch(/Malformed/)
})

it("should have access to environment variables", async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export async function getHeaders(
}
throw new Error(`Header command exited unexpectedly: ${error}`)
}
if (!result.stdout) {
// Allow no output for parity with the Coder CLI.
return headers
}
const lines = result.stdout.replace(/\r?\n$/, "").split(/\r?\n/)
for (let i = 0; i < lines.length; ++i) {
const [key, value] = lines[i].split(/=(.*)/)
Expand Down