https://github.com/gemmaro/mruby-uriparser
URI parsing for mruby
https://github.com/gemmaro/mruby-uriparser
mruby parser uri
Last synced: 7 months ago
JSON representation
URI parsing for mruby
- Host: GitHub
- URL: https://github.com/gemmaro/mruby-uriparser
- Owner: gemmaro
- License: gpl-3.0
- Created: 2025-08-15T02:34:10.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-08-30T00:26:49.000Z (7 months ago)
- Last Synced: 2025-09-01T06:50:16.361Z (7 months ago)
- Topics: mruby, parser, uri
- Language: C
- Homepage:
- Size: 90.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# mruby uriparser
mruby uriparser provides [uriparser](https://uriparser.github.io/) bindings for [mruby](https://mruby.org/).
## Installation
Add the following to your `build_config.rb`:
```ruby
conf.linker.libraries << 'uriparser'
```
## Usage
```ruby
str = "http://user:pass@example.com:8000/some-path?some-query#some-fragment"
uri = URIParser.parse(str)
uri.class #=> URIParser::URI
uri.scheme #=> "http"
uri.userinfo #=> "user:pass"
uri.host #=> "example.com"
uri.port #=> "8000"
uri.query #=> "some-query"
uri.fragment #=> "some-fragment"
uri.to_s #=> same as str
```
You may use a constant alias for convenience:
```ruby
URI = URIParser::URI
```
## Features
Below is a comparison of supported features with CRuby's URI gem.
A dash (`-`) indicates not supported or no plans to support.
| mruby uriparser | CRuby URI gem |
|-------------------------------------------------------|-----------------------------------------------------|
| `URIParser::URI#decode_www_form`[^1] | `URI.decode_www_form` |
| - | `URI.decode_www_form_component` |
| `URIParser.encode_www_form`[^2] | `URI.encode_www_form` |
| - | `URI.encode_www_form_component` |
| - | `URI.extract`[^4] |
| `URIParser.join`, `URIParser::URI.join` | `URI.join` |
| `URIParser.parse`, `URIParser::URI.parse` | `URI.parse` |
| - | `URI.regexp`[^3] |
| - | `URI.split` |
| - | `URI::UNSAFE` |
| - | `URI::Generic.build` |
| - | `URI::Generic.build2` |
| - | `URI::Generic.component` |
| - | `URI::Generic.default_port` |
| - | `URI::Generic.new` |
| - | `URI::Generic.use_registry` |
| `URIParser::URI#merge`, `URIParser::URI#@+`[^5] | `URI::Generic#merge`, `URI::Generic#@+` |
| `URIParser::URI#route_from`, `URIParser::URI#@-` | `URI::Generic#route_from`, `URI::Generic#@-` |
| - | `URI::Generic#==` |
| `URIParser::URI#absolute`, `URIParser::URI#absolute?` | `URI::Generic#absolute`, `URI::Generic#absolute?` |
| - | `URI::Generic#coerce` |
| - | `URI::Generic#component` |
| - | `URI::Generic#find_proxy` |
| `URIParser::URI#fragment` | `URI::Generic#fragment` |
| - | `URI::Generic#fragment=` |
| `URIParser::URI#hierarchical?` | `URI::Generic#hierarchical?` |
| - | `URI::Generic#host` |
| - | `URI::Generic#host=` |
| `URIParser::URI#hostname` | `URI::Generic#hostname` |
| - | `URI::Generic#hostname=` |
| `URIParser::URI#merge!` | `URI::Generic#merge!` |
| `URIParser::URI#normalize!` | `URI::Generic#normalize`, `URI::Generic#normalize!` |
| - | `URI::Generic#opaque` |
| - | `URI::Generic#opaque=` |
| - | `URI::Generic#parser` |
| - | `URI::Generic#password` |
| - | `URI::Generic#password=` |
| - | `URI::Generic#path` |
| - | `URI::Generic#path=` |
| - | `URI::Generic#port` |
| - | `URI::Generic#port=` |
| `URIParser::URI#query` | `URI::Generic#query` |
| - | `URI::Generic#query=` |
| - | `URI::Generic#registry` |
| - | `URI::Generic#registry=` |
| `URIParser::URI#relative?` | `URI::Generic#relative?` |
| `URIParser::URI#route_to` | `URI::Generic#route_to` |
| `URIParser::URI#scheme` | `URI::Generic#scheme` |
| - | `URI::Generic#scheme=` |
| - | `URI::Generic#select` |
| `URIParser::URI#to_s` | `URI::Generic#to_s` |
| - | `URI::Generic#user` |
| - | `URI::Generic#user=` |
| `URIParser::URI#userinfo` | `URI::Generic#userinfo` |
| - | `URI::Generic#userinfo=` |
| - | `URI::Generic::COMPONENT` |
| - | `URI::Generic::DEFAULT_PORT` |
[^1]: No `enc=Encoding::UTF_8` parameter as in CRuby's URI gem.
[^2]: Only supports `Array[String, String | nil]` for `enum`. No `enc=nil` parameter.
[^3]: Obsolete since Ruby 2.2.
[^4]: Obsolete since Ruby 2.2.
[^5]: Relative path must be a URI. See API docs.
Refer to the API documentation for details.
## Running Tests
To run tests:
```shell
rake --directory /path/to/mruby all test MRUBY_CONFIG=$PWD/build_config.rb
```
Alternatively, use the `test/run` script with `MRUBY_SRC` set in your `.env` file.
## Prior Work
See [mruby-uri-parser](https://github.com/Asmod4n/mruby-uri-parser), which uses [uri\_parser](https://github.com/Zewo/uri_parser).
## License
Copyright (C) 2025 gemmaro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .