mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-04-14 08:28:23 +02:00
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:
@@ -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!
|
||||||
|
|||||||
Reference in New Issue
Block a user