fix: closes #13199 normalize accept header

@julianlam tried accepts module ran into issues when the route was requested via browser or via $.ajax with the default headers,
for example accepts(req).type(activitypub._constants.acceptableTypes) still returns true when /post/123 is loaded via browser or via $.ajax
This commit is contained in:
Barış Soner Uşaklı
2026-01-20 22:19:22 -05:00
parent 7bc9fe3b75
commit ec4e7ef1b7
2 changed files with 6 additions and 5 deletions

View File

@@ -65,10 +65,11 @@ Helpers.isUri = (value) => {
}); });
}; };
Helpers.assertAccept = accept => (accept && accept.split(',').some((value) => { Helpers.assertAccept = (accept) => {
const parts = value.split(';').map(v => v.trim()); if (!accept) return false;
return activitypub._constants.acceptableTypes.includes(value || parts[0]); const normalized = accept.split(',').map(s => s.trim().replace(/\s*;\s*/g, ';')).join(',');
})); return activitypub._constants.acceptableTypes.some(type => normalized.includes(type));
};
Helpers.isWebfinger = (value) => { Helpers.isWebfinger = (value) => {
// N.B. returns normalized handle, so truthy check! // N.B. returns normalized handle, so truthy check!