Infer.Text (Infer v0.2.0) View Source

Text type matchers based on the magic number

Link to this section Summary

Functions

Takes the binary file contents as arguments. Returns true if it's html.

Takes the binary file contents as arguments. Returns true if it's a shell script.

Takes the binary file contents as arguments. Returns true if it's xml.

Link to this section Functions

Specs

html?(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's html.

See: https://mimesniff.spec.whatwg.org/

Examples

iex> Infer.Text.html?("<!DOCTYPE html>")
true

iex> Infer.Text.html?("     <BODY>")
true

iex> Infer.Text.html?("<")
false

Specs

shell_script?(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a shell script.

Specs

xml?(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's xml.

See: https://mimesniff.spec.whatwg.org/