Skip to content
OpenResty library for parsing URI
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
benchmark
bin
rockspecs
spec/resty
src/resty
.busted
.codeclimate.yml
.gitignore
.luacheckrc
CHANGELOG.md
LICENSE
Makefile
README.md
Roverfile
Roverfile.lock
dist.ini

README.md

lua-resty-url CircleCI

lua-resty-url - URL parser for OpenResty.

Table of Contents

Status

This library is considered production ready.

Description

This Lua library is very simple Regex based URL parser.

This library can parse URLs and split them to components.

Synopsis

http {
    server {
        location /test {
            content_by_lua_block {
                local resty_url = require 'resty.url'

                ngx.say("USER: ", resty_url.parse('http://foo:bar@example.com').user)
            }
        }
    }
}

Back to TOC

Methods

All the methods are expected to be called on the module without self.

Back to TOC

split

syntax: parts = resty_url.split(url)

Returns a table with integer keys and parts of the URL. Components are: scheme, user, password, host, port, path.

Back to TOC

parse

syntax: uri = resty_url.parse(url)

Returns a table with components as keys. Components are: scheme, user, password, host, port, path.

Back to TOC

join

syntax: url = resty_url.join(base, part, ...)

Concatenates URI components into resulting URL. Also normalizes URI to remove double slashes. Can concatenate objects returned by parse method.

Back to TOC

default_port

syntax: port = resty_url.default_port(scheme)

Returns default port for given scheme. Only http and https provided by default.

Back to TOC

normalize

syntax: uri = resty_url.normalize(uri)

Removes unnecessary slashes from the URI.

Back to TOC

Installation

If you are using the OpenResty bundle (http://openresty.org ), then you can use opm to install this package.

opm get 3scale/lua-resty-url

Back to TOC

Bugs and Patches

Please report bugs or submit patches by

  1. creating a ticket on the GitHub Issue Tracker,

Back to TOC

Author

Michal "mikz" Cichra mcichra@redhat.com, Red Hat Inc.

Back to TOC

Copyright and License

This module is licensed under the Apache License Version 2.0.

Copyright (C) 2016-2017, Red Hat Inc.

All rights reserved.

See LICENSE for the full license.

Back to TOC

See Also

Back to TOC

You can’t perform that action at this time.