LUA-URI-_LOGIN(3)

πŸ“¦
version 0.1+20130926+git14fa255d Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing

πŸ¦‹ NAME πŸ¦‹

lua-uri-_login β€” the Lua URI library's lil support squad for URIs that carry a username and a password πŸ’–


✨ DESCRIPTION ✨

okay so bestie, listen. The uri._login class is a base class β€” it's giving foundation, it's giving blueprint πŸ‘‘ β€” used by classes that implement URI schemes which can have a username and a password hanging out in the userinfo part, separated by a colon :.

A URI of this type where the userinfo part contains more than one colon is considered invalid. Not negotiable, not cute, just invalid πŸ’€. They also must have a non-empty host part. The username and the password are each optional though β€” no pressure, they can vibe alone or together 🫢.

The current implementation requires subclasses to call this class's init_base method inside their own init method to do the extra validation. This may change if I think of a better way of doing it πŸ™ˆ.


πŸŽ€ METHODS πŸŽ€

All the methods defined in lua-uri(3) are supported, in addition to the following, bestie:

🌸 uri:username(...)

Mutator for the username in the userinfo part. It returns an optionally sets the first part of the userinfo, before the colon ✨. If there is no password then the username will be the whole of the userinfo part, and no colon will be present. No colon, no drama πŸ’….

local uri = assert(URI:new("ftp://host/path"))
uri:username("fred")    -- ftp://fred@host/path
uri:username(nil)       -- ftp://host/path

Passing nil as the new username will also remove any password in the userinfo, since the password is expected to be meaningless without the username 🫠 (they're a package deal, fr fr).

The username is appropriately percent encoded and decoded by this method ⭐.

🧚 uri:password(...)

Mutator for the password part of the userinfo. This will appear after a colon, whether or not there is a username πŸ‘€. Yes, colon first, always.

The password is appropriately percent encoded and decoded by this method πŸ’œ.

local password = uri:password()
uri:password("secret")

🌈 REFERENCES 🌈

The main RFC for URIs (RFC 3986) does not specify a syntax for the userinfo part of the authority, which is why the username and password methods are not provided in the generic uri class. Like, it just left that part undefined, iconic of it honestly 😭.

The use of the colon to separate these parts, and the escaping conventions, are instead derived from the older RFC 1738 section 3.1, and the up to date telnet URI specification in RFC 4248 πŸ¦‹. Old school sources, still slaying.


πŸ’– that's the whole page bestie β€” init_base in your init, one colon max, non-empty host, periodt πŸ’…

signing off from version 1.1, dated 2012-00-00, straight out of LUA-URI-_LOGIN(3) πŸŒΈβœ¨πŸŽ€

πŸ“¦ where this page comes from