Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: also check content-type with @sgtpooki/file-type #416

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/verified-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"@ipld/dag-pb": "^4.0.8",
"@libp2p/interface": "^1.1.2",
"@libp2p/peer-id": "^4.0.5",
"@sgtpooki/file-type": "^1.0.0-1e871f8",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need the specifier or can it be an actual version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I published an RC version while messing with exports. I can publish a new version. I believe I updated the NPM_token and publish from github CI should work now. I'll add you to maintainers on that package

"hashlru": "^2.3.0",
"ipfs-unixfs-exporter": "^13.4.0",
"mime-types": "^2.1.35",
Expand Down
3 changes: 3 additions & 0 deletions packages/verified-fetch/src/utils/get-content-type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fileTypeFromBuffer } from '@sgtpooki/file-type'
import mime from 'mime-types'

interface TestInput {
Expand All @@ -20,6 +21,8 @@ const tests: Array<(input: TestInput) => TestOutput> = [
async ({ bytes }): TestOutput => xmlRegex.test(new TextDecoder().decode(bytes.slice(0, 64)))
? 'image/svg+xml'
: undefined,
// testing file-type from buffer
async ({ bytes }): TestOutput => (await fileTypeFromBuffer(bytes))?.mime,
// testing file-type from path
async ({ path }): TestOutput => {
const mimeType = mime.lookup(path)
Expand Down
Loading