{"id":13636188,"url":"https://github.com/golgote/neturl","last_synced_at":"2025-04-07T12:06:01.045Z","repository":{"id":1897046,"uuid":"2823545","full_name":"golgote/neturl","owner":"golgote","description":"URL and Query string parser, builder, normalizer for Lua","archived":false,"fork":false,"pushed_at":"2023-01-30T13:32:09.000Z","size":48,"stargazers_count":240,"open_issues_count":8,"forks_count":79,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-02-13T21:51:04.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/golgote.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-21T22:16:19.000Z","updated_at":"2024-02-11T02:40:36.000Z","dependencies_parsed_at":"2023-02-16T07:45:41.116Z","dependency_job_id":null,"html_url":"https://github.com/golgote/neturl","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golgote%2Fneturl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golgote%2Fneturl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golgote%2Fneturl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golgote%2Fneturl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golgote","download_url":"https://codeload.github.com/golgote/neturl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648976,"owners_count":20972945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T00:00:58.287Z","updated_at":"2025-04-07T12:06:01.006Z","avatar_url":"https://github.com/golgote.png","language":"Lua","funding_links":[],"categories":["Libraries","Lua","Resources"],"sub_categories":["Libraries"],"readme":"## A Robust URL Parser and Builder for Lua\n\nThis small Lua library provides a few functions to parse URL with querystring and build new URL easily.\n\n```lua\nurl = require \"net.url\"\n```\n\n### URL parser\n\nThe library converts an URL to a table of the elements as described in RFC : scheme, host, path, etc.\n\n```lua\nu = url.parse(\"http://www.example.com/test/?start=10\")\nprint(u.scheme)\n-- http\nprint(u.host)\n-- www.example.com\nprint(u.path)\n-- /test/\n```\n\n### URL normalization\n\n```lua\nu = url.parse(\"http://www.FOO.com:80///foo/../foo/./bar\"):normalize()\nprint(u)\n-- http://www.foo.com/foo/bar\n```\n\n### URL resolver\n\nURL resolution follows the examples provided in the [RFC 2396](http://tools.ietf.org/html/rfc2396#appendix-C).\n\n```lua\nu = url.parse(\"http://a/b/c/d;p?q\"):resolve(\"../../g\")\nprint(u)\n-- http://a/g\n```\n\n### Path builder\n\nPath segments can be added using the `__div` metatable or `u.addSegment()`.\n\n```lua\nu = url.parse('http://example.com')\nu / 'bands' / 'AC/DC'\nprint(u)\n-- http://example.com/bands/AC%2FDC\n```\n\n### Module Options\n\n- `separator` is used to specify which separator is used between query parameters. It is `\u0026` by default.\n- `cumulative_parameters` is false by default. If true, query parameters with the same name will be stored in a table.\n- `legal_in_path` is a table of characters that will not be url encoded in path components.\n- `legal_in_query` is a table of characters that will not be url encoded in query values. Query parameters on the other hand only support a small set of legal characters (`-_.`).\n- `query_plus_is_space` is true by default, so a plus sign in a query value will be converted to %20 (space), not %2B (plus).\n\nIf one wants to have the `+` sign as is in path segments, one can add it to the list of\nlegal characters in path. For example:\n\n```lua\nurl = require \"net.url\"\nurl.options.legal_in_path[\"+\"] = true;\n```\n\n### Querystring parser\n\nThe library supports brackets in querystrings, like PHP. It means you can use brackets to build multi-dimensional tables. The parsed querystring has a tostring() helper. As usual with Lua, if no index is specified, it starts from index 1.\n\n```lua\nquery = url.parseQuery(\"first=abc\u0026a[]=123\u0026a[]=false\u0026b[]=str\u0026c[]=3.5\u0026a[]=last\")\nprint(query)\n-- a[1]=123\u0026a[2]=false\u0026a[3]=last\u0026b[1]=str\u0026c[1]=3.5\u0026first=abc\nprint(query.a[1])\n-- 123\n```\n\n### Querystring builder\n\n```lua\nu = url.parse(\"http://www.example.com\")\nu.query.foo = \"bar\"\nprint(u)\n-- http://www.example.com/?foo=bar\n\nu:setQuery{ json = true, skip = 100 }\nprint(u)\n-- http://www.example.com/?json=true\u0026skip=100\n```\n\n### Differences with luasocket/url.lua\n\n- Luasocket/url.lua can't parse http://www.example.com?url=net correctly because there are no path.\n- Luasocket/url.lua can't clean and normalize url, for example by removing default port, extra zero in port, empty authority, uppercase scheme, domain name.\n- Luasocket/url.lua doesn't parse the query string parameters.\n- Luasocket/url.lua is less compliant with RFC 2396 and will resolve `http://a/b/c/d;p?q` and :\n    `../../../g` to `http://ag` instead of `http://a/g`\n    `../../../../g` to `http://a../g` instead of `http://a/g`\n    `g;x=1/../y` to `http://a/b/c/g;x=1/../y` instead of `http://a/b/c/y`\n    `/./g` to `http://a/./g` instead of `http://a/g`\n    `g;x=1/./y` to `http://a/b/c/g;x=1/./y` instead of `http://a/b/c/g;x=1/y`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolgote%2Fneturl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolgote%2Fneturl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolgote%2Fneturl/lists"}