Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Mar 31, 2022
1 parent fdfefdd commit ec41466
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Contribute
Contributions to **mimetype** are welcome. If you find an issue and you consider
contributing, you can use the [Github issues tracker](https://github.com/gabriel-vasile/mimetype/issues)
contributing, you can use the [Github issues tracker](https://github.com/wailsapp/mimetype/issues)
in order to report it, or better yet, open a pull request.

Code contributions must respect these rules:
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<a href="https://travis-ci.org/gabriel-vasile/mimetype">
<img alt="Build Status" src="https://travis-ci.org/gabriel-vasile/mimetype.svg?branch=master">
</a>
<a href="https://pkg.go.dev/github.com/gabriel-vasile/mimetype">
<img src="https://pkg.go.dev/badge/github.com/gabriel-vasile/mimetype.svg" alt="Go Reference">
<a href="https://pkg.go.dev/github.com/wailsapp/mimetype">
<img src="https://pkg.go.dev/badge/github.com/wailsapp/mimetype.svg" alt="Go Reference">
</a>
<a href="https://goreportcard.com/report/github.com/gabriel-vasile/mimetype">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/gabriel-vasile/mimetype">
<a href="https://goreportcard.com/report/github.com/wailsapp/mimetype">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/wailsapp/mimetype">
</a>
<a href="https://coveralls.io/github/gabriel-vasile/mimetype?branch=master">
<img alt="Go report card" src="https://coveralls.io/repos/github/gabriel-vasile/mimetype/badge.svg?branch=master">
Expand All @@ -30,14 +30,14 @@
## Features
- fast and precise MIME type and file extension detection
- long list of [supported MIME types](supported_mimes.md)
- posibility to [extend](https://pkg.go.dev/github.com/gabriel-vasile/mimetype#example-package-Extend) with other file formats
- posibility to [extend](https://pkg.go.dev/github.com/wailsapp/mimetype#example-package-Extend) with other file formats
- common file formats are prioritized
- [text vs. binary files differentiation](https://pkg.go.dev/github.com/gabriel-vasile/mimetype#example-package-TextVsBinary)
- [text vs. binary files differentiation](https://pkg.go.dev/github.com/wailsapp/mimetype#example-package-TextVsBinary)
- safe for concurrent usage

## Install
```bash
go get github.com/gabriel-vasile/mimetype
go get github.com/wailsapp/mimetype
```

## Usage
Expand All @@ -49,7 +49,7 @@ mtype, err := mimetype.DetectReader(io.Reader)
mtype, err := mimetype.DetectFile("/path/to/file")
fmt.Println(mtype.String(), mtype.Extension())
```
See the [runnable Go Playground examples](https://pkg.go.dev/github.com/gabriel-vasile/mimetype#pkg-overview).
See the [runnable Go Playground examples](https://pkg.go.dev/github.com/wailsapp/mimetype#pkg-overview).

## Usage'
Only use libraries like **mimetype** as a last resort. Content type detection
Expand All @@ -71,7 +71,7 @@ mimetype.SetLimit(0) // No limit, whole file content used.
mimetype.DetectFile("file.doc")
```
If increasing the limit does not help, please
[open an issue](https://github.com/gabriel-vasile/mimetype/issues/new?assignees=&labels=&template=mismatched-mime-type-detected.md&title=).
[open an issue](https://github.com/wailsapp/mimetype/issues/new?assignees=&labels=&template=mismatched-mime-type-detected.md&title=).

## Structure
**mimetype** uses a hierarchical structure to keep the MIME type detection logic.
Expand All @@ -83,11 +83,11 @@ zip, there is no need to check if it is a text file, but it is worth checking if
it is an Microsoft Office file.

To prevent loading entire files into memory, when detecting from a
[reader](https://pkg.go.dev/github.com/gabriel-vasile/mimetype#DetectReader)
or from a [file](https://pkg.go.dev/github.com/gabriel-vasile/mimetype#DetectFile)
[reader](https://pkg.go.dev/github.com/wailsapp/mimetype#DetectReader)
or from a [file](https://pkg.go.dev/github.com/wailsapp/mimetype#DetectFile)
**mimetype** limits itself to reading only the header of the input.
<div align="center">
<img alt="structure" src="https://github.com/gabriel-vasile/mimetype/blob/420a05228c6a6efbb6e6f080168a25663414ff36/mimetype.gif?raw=true" width="88%">
<img alt="structure" src="https://github.com/wailsapp/mimetype/blob/420a05228c6a6efbb6e6f080168a25663414ff36/mimetype.gif?raw=true" width="88%">
</div>

## Performance
Expand Down
2 changes: 1 addition & 1 deletion example_mimetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"os"

"github.com/gabriel-vasile/mimetype"
"github.com/wailsapp/mimetype"
)

func Example_detect() {
Expand Down
2 changes: 1 addition & 1 deletion example_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"io/ioutil"

"github.com/gabriel-vasile/mimetype"
"github.com/wailsapp/mimetype"
)

// Pure io.Readers (meaning those without a Seek method) cannot be read twice.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/gabriel-vasile/mimetype
module github.com/wailsapp/mimetype

go 1.12

Expand Down
4 changes: 2 additions & 2 deletions internal/magic/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/gabriel-vasile/mimetype/internal/charset"
"github.com/gabriel-vasile/mimetype/internal/json"
"github.com/wailsapp/mimetype/internal/charset"
"github.com/wailsapp/mimetype/internal/json"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package mimetype
import (
"mime"

"github.com/gabriel-vasile/mimetype/internal/charset"
"github.com/gabriel-vasile/mimetype/internal/magic"
"github.com/wailsapp/mimetype/internal/charset"
"github.com/wailsapp/mimetype/internal/magic"
)

// MIME struct holds information about a file format: the string representation
Expand Down
10 changes: 5 additions & 5 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mimetype
import (
"sync"

"github.com/gabriel-vasile/mimetype/internal/magic"
"github.com/wailsapp/mimetype/internal/magic"
)

// mimetype stores the list of MIME types in a tree structure with
Expand Down Expand Up @@ -88,7 +88,7 @@ var (
php = newMIME("text/x-php", ".php", magic.Php)
rtf = newMIME("text/rtf", ".rtf", magic.Rtf)
js = newMIME("application/javascript", ".js", magic.Js).
alias("application/x-javascript", "text/javascript")
alias("application/x-javascript", "text/javascript")
srt = newMIME("application/x-subrip", ".srt", magic.Srt).
alias("application/x-srt", "text/x-srt")
vtt = newMIME("text/vtt", ".vtt", magic.Vtt)
Expand All @@ -101,7 +101,7 @@ var (
iCalendar = newMIME("text/calendar", ".ics", magic.ICalendar)
svg = newMIME("image/svg+xml", ".svg", magic.Svg)
rss = newMIME("application/rss+xml", ".rss", magic.Rss).
alias("text/rss")
alias("text/rss")
owl2 = newMIME("application/owl+xml", ".owl", magic.Owl2)
atom = newMIME("application/atom+xml", ".atom", magic.Atom)
x3d = newMIME("model/x3d+xml", ".x3d", magic.X3d)
Expand Down Expand Up @@ -146,7 +146,7 @@ var (
ape = newMIME("audio/ape", ".ape", magic.Ape)
musePack = newMIME("audio/musepack", ".mpc", magic.MusePack)
wav = newMIME("audio/wav", ".wav", magic.Wav).
alias("audio/x-wav", "audio/vnd.wave", "audio/wave")
alias("audio/x-wav", "audio/vnd.wave", "audio/wave")
aiff = newMIME("audio/aiff", ".aiff", magic.Aiff).alias("audio/x-aiff")
au = newMIME("audio/basic", ".au", magic.Au)
amr = newMIME("audio/amr", ".amr", magic.Amr).
Expand All @@ -166,7 +166,7 @@ var (
quickTime = newMIME("video/quicktime", ".mov", magic.QuickTime)
mqv = newMIME("video/quicktime", ".mqv", magic.Mqv)
threeGP = newMIME("video/3gpp", ".3gp", magic.ThreeGP).
alias("video/3gp", "audio/3gpp")
alias("video/3gp", "audio/3gpp")
threeG2 = newMIME("video/3gpp2", ".3g2", magic.ThreeG2).
alias("video/3g2", "audio/3gpp2")
avi = newMIME("video/x-msvideo", ".avi", magic.Avi).
Expand Down

0 comments on commit ec41466

Please sign in to comment.