Skip to content

feat: support header matching in edge functions#361

Merged
eduardoboucas merged 3 commits intomainfrom
feat/ef-header-match
Jul 18, 2025
Merged

feat: support header matching in edge functions#361
eduardoboucas merged 3 commits intomainfrom
feat/ef-header-match

Conversation

@eduardoboucas
Copy link
Member

@eduardoboucas eduardoboucas requested a review from a team as a code owner July 18, 2025 09:00
@eduardoboucas eduardoboucas changed the title feat; support header matching in edge functions feat: support header matching in edge functions Jul 18, 2025
Comment on lines +134 to +142
const requestHeaderValue = req.headers.get(headerName)?.split(', ').join(',')

if (headerMatch?.matcher === 'exists') {
return Boolean(requestHeaderValue)
}

if (headerMatch?.matcher === 'missing') {
return !requestHeaderValue
}
Copy link
Contributor

@pieh pieh Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work as expected if header has empty string? I'm not sure how useful looking into such case is (do empty string header value happen in practice?), but:

Boolean((new Headers({ 'test': ''})).get('test').split(',').join(','))

would be false, so it would not pass exists check for test header and would pass missing check, but I dunno if this would be a bug or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b343ca1.

eduardoboucas and others added 2 commits July 18, 2025 11:41
Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
@eduardoboucas eduardoboucas requested a review from pieh July 18, 2025 10:48
@eduardoboucas eduardoboucas merged commit 05791fb into main Jul 18, 2025
13 of 14 checks passed
@eduardoboucas eduardoboucas deleted the feat/ef-header-match branch July 18, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants