UAInspector v0.19.0 UAInspector.Util View Source
Utility methods.
Link to this section Summary
Functions
Upgrades a database regex into a detection regex
Replaces an empty string with :unknown
Sanitizes a model string
Sanitizes a name string
Sanitizes a version string
Converts an unknown version string to a semver-comparable format
Replaces PHP-Style regex captures with their values
Link to this section Functions
build_regex(regex) View Source
Upgrades a database regex into a detection regex.
This prevents matching a string with other characters before the matching part.
maybe_unknown(data) View Source
Replaces an empty string with :unknown
.
sanitize_model(model) View Source
Sanitizes a model string.
sanitize_name(name) View Source
Sanitizes a name string.
sanitize_version(version) View Source
Sanitizes a version string.
to_semver(version) View Source
Converts an unknown version string to a semver-comparable format.
Everything except the major
and minor
version is dropped as
these two parts are the only available/needed.
Missing values are filled with zeroes while empty strings are ignored.
If a non-integer value is found it is ignored and every part including and after it will be a zero.
Examples
iex> to_semver("15")
"15.0.0"
iex> to_semver("3.6")
"3.6.0"
iex> to_semver("8.8.8")
"8.8.0"
iex> to_semver("")
""
iex> to_semver("invalid")
"0.0.0"
iex> to_semver("3.help")
"3.0.0"
iex> to_semver("0.1.invalid")
"0.1.0"
uncapture(data, captures) View Source
Replaces PHP-Style regex captures with their values.