(
entity: string | ReturnType<TextEncoder["encode"]> | FileInfo,
options: ETagOptions = {},
)
| 149 | options?: ETagOptions, |
| 150 | ): Promise<string | undefined>; |
| 151 | export async function eTag( |
| 152 | entity: string | ReturnType<TextEncoder["encode"]> | FileInfo, |
| 153 | options: ETagOptions = {}, |
| 154 | ): Promise<string | undefined> { |
| 155 | const weak = options.weak ?? isFileInfo(entity); |
| 156 | const tag = |
| 157 | await (isFileInfo(entity) |
| 158 | ? calcFileInfo(entity, options) |
| 159 | : calcEntity(entity, options)); |
| 160 | |
| 161 | if (!tag) { |
| 162 | return undefined; |
| 163 | } |
| 164 | |
| 165 | return weak ? `W/"${tag}"` : `"${tag}"`; |
| 166 | } |
| 167 | |
| 168 | const STAR_REGEXP = /^\s*\*\s*$/; |
| 169 | const COMMA_REGEXP = /\s*,\s*/; |
no test coverage detected