Gluaurl
gluaurl: a url parser/builder module for gopher-lua
Install / Use
/learn @cjoudrey/GluaurlREADME
gluaurl
gluahttp provides an easy way to parse and build URLs from within GopherLua.
Installation
go get github.com/cjoudrey/gluaurl
Usage
import "github.com/yuin/gopher-lua"
import "github.com/cjoudrey/gluaurl"
func main() {
L := lua.NewState()
defer L.Close()
L.PreloadModule("url", gluaurl.Loader)
if err := L.DoString(`
local url = require("url")
parsed_url = url.parse("http://example.com/")
print(parsed_url.host)
`); err != nil {
panic(err)
}
}
API
url.parse(url)
Parse URL into a table of key/value components.
Attributes
| Name | Type | Description | | ------- | ------ | ----------- | | url | String | URL to parsed |
Returns
Table with parsed URL or (nil, error message)
| Name | Type | Description | | -------- | ------ | ----------- | | scheme | String | Scheme of the URL | | username | String | Username | | password | String | Password | | host | String | Host and port of the URL | | path | String | Path | | query | String | Query string | | fragment | String | Fragment |
url.build(options)
Assemble a URL string from a table of URL components.
Attributes
| Name | Type | Description |
| ------- | ----- | ----------- |
| options | Table | Table with URL components, see url.parse for list of valid components |
Returns
String
url.build_query_string(query_params)
Assemble table of query string parameters into a string.
Attributes
| Name | Type | Description | | ------------ | ----- | ----------- | | query_params | Table | Table with query parameters |
Returns
String
url.resolve(from, to)
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.
| Name | Type | Description | | ---- | ------ | ----------- | | from | String | base URL | | to | String | href URL |
Returns
String or (nil, error message)
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
