mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
feat(api): serve well-known discovery with etag and 304 (#2349)
This commit is contained in:
1 parent
5719dfe8a3
commit
4f48e04cad
4 files changed
+74
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function stripWeakness(entityTag: string): string {
|
||||
return entityTag.startsWith('W/') ? entityTag.slice(2) : entityTag;
|
||||
}
|
||||
|
||||
export function entityTagMatches(ifNoneMatch: string, etag: string): boolean {
|
||||
const target = stripWeakness(etag.trim());
|
||||
return ifNoneMatch
|
||||
.split(',')
|
||||
.map((candidate) => candidate.trim())
|
||||
.some((candidate) => candidate === '*' || stripWeakness(candidate) === target);
|
||||
}
|
||||
Reference in new issue
Block a user