Skip to content

Commit fd29ac5

Browse files
feat: support raw-http annotation
1 parent f24c22f commit fd29ac5

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/lib/run-dev.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,11 @@ function isWebAction (action) {
251251
function isRawWebAction (action) {
252252
const raw = 'raw'
253253
const webExportValue = action?.annotations?.['web-export']
254+
const rawHttpValue = action?.annotations?.['raw-http']
255+
const isRawHttp = rawHttpValue === true || rawHttpValue === 'yes' || rawHttpValue === 'true'
254256
const webValue = action?.web
255257

256-
return (webExportValue === raw || webValue === raw)
258+
return (webExportValue === raw || webValue === raw || isRawHttp)
257259
}
258260

259261
/**

test/lib/run-dev.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,32 @@ describe('isRawWebAction', () => {
520520
})
521521
})
522522

523+
test('action.annotations.raw-http', () => {
524+
let action
525+
526+
action = { annotations: {} }
527+
expect(isRawWebAction(action)).toBeFalsy()
528+
529+
action = { annotations: { 'raw-http': 'raw' } }
530+
expect(isRawWebAction(action)).toBeFalsy()
531+
532+
action = { annotations: { 'raw-http': 'any other string value' } }
533+
expect(isRawWebAction(action)).toBeFalsy()
534+
535+
action = { annotations: { 'raw-http': false } }
536+
expect(isRawWebAction(action)).toBeFalsy()
537+
538+
action = { annotations: { 'raw-http': true } }
539+
expect(isRawWebAction(action)).toBeTruthy()
540+
541+
action = { annotations: { 'raw-http': 'yes' } }
542+
expect(isRawWebAction(action)).toBeTruthy()
543+
544+
action = { annotations: { 'raw-http': 'true' } }
545+
expect(isRawWebAction(action)).toBeTruthy()
546+
})
547+
548+
523549
describe('statusCodeMessage', () => {
524550
test('900 - invalid', () => {
525551
const statusCode = 900

0 commit comments

Comments
 (0)