UserAgent
What an HTTP client says it is (RFC 9110's User-Agent): products and comments, curl/8.7.1. Personal data.
Web and network; not ordered; personal data (online); since Jadpo 0.1.0.
Make one
Build one from its text, UserAgent("curl/8.7.1"), which checks it: text that isn't one breaks format.
text.parse(raw, as: UserAgent) reads one from its text; text that isn't one at all fails malformed, such as (compatible), curl /8.7.1 or Mozilla/5.0 (X11).
Text, JSON and storage
text.from writes its canonical text, the one form text.parse reads back. JSON sends its canonical text as a string.
| Text | JSON |
|---|---|
curl/8.7.1 |
"curl/8.7.1" |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 |
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" |
ExampleBot/1.0 (+https://example.com/bot) |
"ExampleBot/1.0 (+https://example.com/bot)" |
It is stored in one column named for the field, of type text. Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 is stored as 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'.
Shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
curl/8.7.1 |
curl/8.7.1 |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 |
ExampleBot/1.0 (+https://example.com/bot) |
ExampleBot/1.0 (+https://example.com/bot) |
Operations
It has the contract's own operations: text.parse, text.from, text.format, json.read, json.write and ==. It isn't ordered, so < and sorting don't take it. Every standard type meets one contract says how they work.
Markdown for agents: /docs/types/type-user-agent.md.Built from Jadpo main at e00e61f.