LUA-URI-DATA(3)
LUA-URI-DATA π β¨
okay bestie, this is the lua-uri-data page from the Lua uri.data module β yes it's a real manual page, yes I read all of it, and yes I'm gonna make it make sense. sit down, grab a strawberry π, we're doing this.
NAME π
lua-uri-data β it's the whole data URI support situation for the Lua URI library. that's it. that's the name.
DESCRIPTION π¦
so the class uri.data is the one you use for URIs that have the data scheme. it's a subclass situation β it inherits from the uri class, so all that energy is in its bloodline. π
some of the features in this module need the lua-datafilter(3) library to be installed first. but β and this is important, bestie β you can still create URI objects from data URIs even if lua-datafilter(3) isn't there. so it's not a hard requirement, just a "some things hit different when it's installed" thing. π«Ά
now the vibe check on validity, because this class is picky and honestly? fair:
- any
dataURI that contains an authority part is considered invalid. no authority. not allowed. periodt. π - also invalid: any URI whose path does not contain a comma. the comma is not optional, she's the main character. π€
- and if the URI has the
;base64parameter, then the data must consist only of characters that are allowed in base64 encoded data. that means: upper and lowercase ASCII letters, digits, and the forward slash and plus characters. that's the whole guest list, nobody else gets in. β¨
METHODS πΈ
every single method defined in lua-uri(3) is supported here. full inheritance, she got it from her mama. π
but there are three that act a little special:
userinfoβ always returnsnil. and if you pass it anything that isn'tnil, it will throw an exception. it does not want your input bestie. πhostβ same deal. always returnsnil, throws an exception when passed anything other thannil.portβ you already know. alwaysnil, and throws an exception if you pass anything other thannil.
and the path method? she'll throw an exception if you give her a new path that is nil or that isn't valid for the data scheme. so like... bring her something valid or don't bring her anything at all. π
the following extra methods are also supported:
uri:data_bytes(...) π§
get or set the actual data stored in the URI. when you call it, the existing data gets decoded and handed back to you. if you supply a new value it must be a string, and it'll cause the path of the URI to be changed so it encodes that new data. π«
the method is gonna pick whichever encoding results in the smallest URI β efficiency queen, we love her β unless the datafilter module isn't installed, in which case it will always just use percent encoding. no datafilter, no choices. π€·βοΈ
warning bestie: an exception is thrown if the datafilter module is not installed and the data in the URI is encoded as base64. but β a data URI using percent encoding will not cause an exception. so percent encoding is the safe one when datafilter is MIA. π
one more thing: the data you pass in and the data you get back should not be encoded in any special way. the library handles all of that for you, that's literally her job. π
uri:data_media_type(...) π
get or set the media type (aka the MIME type) that's stored in the URI's path, before the comma. and heads up: this should not include the ;base64 parameter, because that one gets included in the path automatically whenever it's appropriate. she handles it, don't worry about it. β¨
if there's no media type given in the URI at all, then the default value of text/plain gets returned. and if there's no charset parameter given, then the default ;charset=US-ASCII will be included. defaults on defaults, she's generous like that. π
and yes, the media type is encoded and decoded automatically by this method. you don't lift a finger. π«Ά
REFERENCES β
this class is based on RFC 2397. that's the source material, the blueprint, the original slay. π₯
okay that's the whole page bestie, you ate that π β¨ version 1.1, dated 2012-00-00, from the Lua uri.data module β go forth and encode responsibly, ily π¦πΈπ
π¦ where this page comes from
- debian trixie: lua-uri 0.1+20130926+git14fa255d-3 Β· MIT
- ubuntu noble: lua-uri 0.1+20130926+git14fa255d-3 Β· MIT
- ubuntu questing: lua-uri 0.1+20130926+git14fa255d-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms