Skip to content

Commit

Permalink
Extend ZnMimeType>>#isBinary to do more effort to recognize textual t…
Browse files Browse the repository at this point in the history
…ypes, but it remains a heuristic
  • Loading branch information
svenvc committed Nov 15, 2023
1 parent a9f195e commit 571eb28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ testing
isBinary
"Answers whether the contents of a resource described by me
should be considered as binary instead of textual."


| subParts |
self main = 'text'
ifTrue: [ ^ false ].
^ (self sub substrings: '+-')
noneSatisfy: [ :each | self class textSubTypeFragments includes: each ]
subParts := self sub substrings: '+-'.
(subParts anySatisfy: [ :subPart |
self class textSubTypeFragments includes: subPart ])
ifTrue: [ ^ false ].
(subParts anySatisfy: [ :subPart |
self class textSubTypeFragments anySatisfy: [ :fragment |
subPart includesSubstring: fragment ] ])
ifTrue: [ ^ false ].
^ true
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ someNonBinaryMimeTypes
'image/svg+xml'
'application/SGML'
'model/x3d+xml'
'application/csv')
'application/csv'
'application/x-ndjson')

0 comments on commit 571eb28

Please sign in to comment.