|
mruby-uriparser
|
mruby uriparser implementation More...
#include "mrb_uriparser.h"#include <mruby/array.h>#include <mruby/boxing_word.h>#include <mruby/data.h>#include <mruby/hash.h>#include <mruby/string.h>#include <mruby/value.h>#include <mruby/variable.h>#include <stdbool.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <uriparser/Uri.h>Data Structures | |
| struct | mrb_uriparser_data |
Internal data structure for wrapping a UriUriA pointer in mruby. More... | |
Macros | |
| #define | MRB_URIPARSER_ERROR(mrb) mrb_class_get_under(mrb, MRB_URIPARSER(mrb), "Error") |
| Error class. | |
| #define | MRB_URIPARSER_NOMEM(mrb) mrb_class_get(mrb, "NoMemoryError") |
| No memory error class. | |
| #define | MRB_URIPARSER_DEFUN_GETTER(component) |
| #define | MRB_URIPARSER_DEFUN_SETTER(component_name) |
| Set the scheme component of the URI. | |
Functions | |
| static mrb_value | mrb_uriparser_parse (mrb_state *const mrb, const mrb_value self) |
| Parse a string into a URI object. | |
| static mrb_value | mrb_uriparser_filename_to_uri_string (mrb_state *const mrb, const mrb_value self) |
| Convert a filename to a URI string. | |
| static mrb_value | mrb_uriparser_uri_string_to_filename (mrb_state *const mrb, const mrb_value self) |
| Convert a URI string to a filename. | |
| static mrb_value | mrb_uriparser_compose_query (mrb_state *const mrb, const mrb_value self) |
| Encode an array of key-value pairs as a WWW form query string. | |
| static mrb_value | mrb_uriparser_initialize_copy (mrb_state *const mrb, const mrb_value self) |
| Copy URI. | |
| static mrb_value | mrb_uriparser_equals (mrb_state *const mrb, const mrb_value self) |
| Check two URIs for equivalence. | |
| static mrb_value | mrb_uriparser_has_host (mrb_state *const mrb, const mrb_value self) |
| Check if the URI has host. | |
| static mrb_value | mrb_uriparser_path_segments (mrb_state *const mrb, const mrb_value self) |
| Get the path segments as an array of strings. | |
| static mrb_value | mrb_uriparser_absolute_path (mrb_state *const mrb, const mrb_value self) |
| Check if the URI has an absolute path. | |
| static mrb_value | mrb_uriparser_recompose (mrb_state *const mrb, const mrb_value self) |
| Serialize the URI to a string. | |
| static mrb_value | mrb_uriparser_merge_mutably (mrb_state *const mrb, const mrb_value self) |
| Mutably resolve a relative URI reference. | |
| static mrb_value | mrb_uriparser_merge (mrb_state *const mrb, const mrb_value self) |
| Immutably resolve a relative URI reference. | |
| static mrb_value | mrb_uriparser_create_reference (mrb_state *const mrb, const mrb_value self) |
| Create a relative reference from a base URI. | |
| static mrb_value | mrb_uriparser_normalize (mrb_state *const mrb, const mrb_value self) |
| Normalize URI components in place. | |
| static mrb_value | mrb_uriparser_dissect_query (mrb_state *const mrb, const mrb_value self) |
| Decode the query string into an array of key-value pairs. | |
mruby uriparser implementation
where uri is kind of URIParser::URI.
where uri is kind of URIParser::URI.
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 | mruby-uri-parser | ruby-uriparser |
|---|---|---|---|
URIParser::URI#decode_www_form |
URI.decode_www_form |
- | - |
| - | URI.decode_www_form_component |
URI.decode |
- |
URIParser.encode_www_form |
URI.encode_www_form |
- | - |
| - | URI.encode_www_form_component |
URI.encode |
- |
| - | URI.extract |
- | - |
|
URI.join |
- | - |
|
URI.parse |
URI.parse |
UriParser::URI.parse |
| - | URI.regexp |
- | - |
| - | URI.split |
- | - |
| - | URI::UNSAFE |
- | - |
| - | URI::Generic.build |
- | - |
| - | URI::Generic.build2 |
- | - |
| - | URI::Generic.component |
- | - |
| - | URI::Generic.default_port |
- | - |
| - | URI::Generic.new |
URI::Parsed.new |
UriParser::URI.new |
| - | URI::Generic.use_registry |
- | - |
|
| - | - |
|
|
- | - |
URIParser::URI#== |
URI::Generic#== |
- | - |
|
|
- | - |
| - | URI::Generic#coerce |
- | - |
| - | URI::Generic#component |
- | - |
| - | URI::Generic#find_proxy |
- | - |
URIParser::URI#fragment |
URI::Generic#fragment |
URI::Parsed#fragment |
UriParser::URI#fragment |
URIParser::URI#fragment= |
URI::Generic#fragment= |
- | UriParser::URI#fragment= |
URIParser::URI#hierarchical? |
URI::Generic#hierarchical? |
- | - |
| - | URI::Generic#host |
URI::Parsed#host |
UriParser::URI#host |
URIParser::URI#host= |
URI::Generic#host= |
- | UriParser::URI#host= |
URIParser::URI#hostname |
URI::Generic#hostname |
- | - |
| - | URI::Generic#hostname= |
- | - |
URIParser::URI#merge! |
URI::Generic#merge! |
- | - |
URIParser::URI#normalize! |
|
- | UriParser::URI#normalize! |
| - | URI::Generic#opaque |
- | - |
| - | URI::Generic#opaque= |
- | - |
| - | URI::Generic#parser |
- | - |
| - | URI::Generic#password |
- | UriParser::URI#password |
| - | URI::Generic#password= |
- | - |
URIParser::URI#path |
URI::Generic#path |
URI::Parsed#path |
UriParser::URI#path |
URIParser::URI#path= |
URI::Generic#path= |
- | UriParser::URI#path= |
URIParser::URI#port |
URI::Generic#port |
URI::Parsed#port |
|
URIParser::URI#port= |
URI::Generic#port= |
- |
|
URIParser::URI#query |
URI::Generic#query |
URI::Parsed#query |
UriParser::URI#query |
URIParser::URI#query= |
URI::Generic#query= |
- | UriParser::URI#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 |
|
UriParser::URI#scheme |
URIParser::URI#scheme= |
URI::Generic#scheme= |
- | UriParser::URI#scheme= |
| - | URI::Generic#select |
- | - |
URIParser::URI#to_s |
URI::Generic#to_s |
URI::Parsed#to_s |
UriParser::URI#to_s |
| - | URI::Generic#user |
- | UriParser::URI#user |
| - | URI::Generic#user= |
- | - |
URIParser::URI#userinfo |
URI::Generic#userinfo |
URI::Parsed#userinfo |
UriParser::URI#userinfo |
URIParser::URI#userinfo= |
URI::Generic#userinfo= |
- | UriParser::URI#userinfo= |
| - | URI::Generic::COMPONENT |
- | - |
| - | URI::Generic::DEFAULT_PORT |
- | - |
URIParser.filename_to_uri_string |
- | - | - |
URIParser.uri_string_to_filename |
- | - | - |
URIParser::URI#path_segments |
- | - | - |
URIParser::URI#absolute_path? |
- | - | - |
URIParser::URI#dup |
? | ? | ? |
URIParser::URI#clone |
? | ? | ? |
URIParser::URI#host? |
? | ? | ? |
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 http://www.gnu.org/licenses/.
| #define MRB_URIPARSER_DEFUN_GETTER | ( | component | ) |
Get the specific component of the URI.
where uri is a URIParser::URI instance.
Note for hostname method: it returns ::1 for http://[::1]/bar so it corresponds to CRuby's URI gem's URI::Generic#hostname method.
nil. | #define MRB_URIPARSER_DEFUN_SETTER | ( | component_name | ) |
Set the scheme component of the URI.
where uri is a URIParser::URI instance.
nil. | #define MRB_URIPARSER_ERROR | ( | mrb | ) | mrb_class_get_under(mrb, MRB_URIPARSER(mrb), "Error") |
Error class.
| #define MRB_URIPARSER_NOMEM | ( | mrb | ) | mrb_class_get(mrb, "NoMemoryError") |
No memory error class.
|
static |
Check if the URI has an absolute path.
There are also the following, which might be slightly different from absolute_path?.
where uri is a URIParser::URI instance.
|
static |
Encode an array of key-value pairs as a WWW form query string.
where query_list is Array of [key, value] pairs. Key is String. Value may be nil or String.
No enc=nil parameter as seen in CRuby's URI gem.
|
static |
Create a relative reference from a base URI.
where base is a base URI (URIParser::URI). If domain_root is true, reference is from domain root.
URIParser::URI instance.
|
static |
Decode the query string into an array of key-value pairs.
where uri is a URIParser::URI instance.
[key, value] pairs. No enc=Encoding::UTF_8 parameter as in CRuby's URI gem.
|
static |
Check two URIs for equivalence.
where uri and another_uri are URIParser::URI instances.
|
static |
Convert a filename to a URI string.
where filename is an absolute filename. If windows is true, use Windows path conversion.
|
static |
Check if the URI has host.
where uri is a URIParser::URI instance.
|
static |
Copy URI.
where uri is a URIParser::URI instance.
|
static |
Immutably resolve a relative URI reference.
where uri is a URIParser::URI instance, and rel is relative URI (URIParser::URI).
URIParser::URI instance.
|
static |
Mutably resolve a relative URI reference.
where uri is a URIParser::URI instance, and rel is relative URI (URIParser::URI).
URIParser::URI instance.
|
static |
Normalize URI components in place.
where uri is kind of URIParser::URI. scheme, userinfo, host, path, query, fragment are for enabling normalization for each component.
URIParser::URI instance.By default all parts are normalized. If path is empty, this doen't set /, which is the difference against CRuby's URI gem's URI::Generic#normalize! method.
|
static |
Parse a string into a URI object.
where str is a URI string to parse.
URIParser::URI instance.
|
static |
Get the path segments as an array of strings.
where uri is a URIParser::URI instance.
|
static |
Serialize the URI to a string.
where uri is a URIParser::URI instance.
Recomposing means serializing.
|
static |
Convert a URI string to a filename.
where uri is a URI string. If windows is true, use Windows path conversion.
where uri is kind of URIParser::URI.