Files
omnivore/packages/content-handler/src/websites/pdf-handler.ts
2022-10-07 16:57:01 +08:00

19 lines
461 B
TypeScript

import { ContentHandler, PreHandleResult } from '../content-handler'
export class PdfHandler extends ContentHandler {
constructor() {
super()
this.name = 'PDF'
}
shouldPreHandle(url: string): boolean {
const u = new URL(url)
const path = u.pathname.replace(u.search, '')
return path.endsWith('.pdf')
}
async preHandle(url: string): Promise<PreHandleResult> {
return Promise.resolve({ contentType: 'application/pdf' })
}
}