Fast URL decoder library
C Python CMake Shell C++ Lua Other
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Faup stands for Finally An Url Parser and is a library and command line tool to parse URLs and normalize fields with two constraints:

  1. Work with real-life urls (resilient to badly formated ones)
  2. Be fast: no allocation for string parsing and read characters only once



Travis Continuous Build

Coverity Scan Build Status

Quick Start

What is provided?

  • A static library you can embed in your software (faup_static)
  • A dynamic library you can get along with (faupl)
  • A command line tool you can use to extract various parts of a url (faup)

Why Yet Another URL Extraction Library?

Because they all suck. Find a library that can extract, say, a TLD even if you have an IP address, or http://localhost, or anything that may confuse your regex so much that you end up with an unmaintainable one.

Command line usage

Simply pipe or give your url as a parameter:

$ echo "" |faup -p

$ faup

If that url is a file, multiple values will be unpacked:

$ cat urls.txt

$ faup -p urls.txt 

Extract only the TLD field

Faup uses the Mozilla list to extract TLDs of level greater than one. Can handle exceptions, etc.

$ faup -f tld

$ faup -f tld

Json output, high level TLDs

The Json output can be called like this:

$ faup -o json
	"scheme": "",
	"credential": "",
	"subdomain": "www",
	"domain": "",
	"domain_without_tld": "takatoukiter",
	"host": "",
	"tld": "",
	"port": "",
	"resource_path": "",
	"query_string": "",
	"fragment": ""

Building faup

To get and build faup, you need cmake. As cmake doesn't allow to build the binary in the source directory, you have to create a build directory.

git clone git://
cd faup
mkdir build
cd build
cmake .. && make
sudo make install

LUA support

Faup can be compiled without LUA support. In that case, CMake will output the following line

-- Could NOT find Lua51 (missing:  LUA_INCLUDE_DIR) 

If you want to add LUA functionnality you need to install lua development headers prior to the previous building steps.

For example, on Redhat systems:

# yum -y install lua lua-devel

CMake 2.8 for Redhat/CentOS 6.x

The following error may appears if you have an outdated version of CMake (just like Redhat and CentOS systems):

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 2.8 or higher is required.  You are running version 2.6.4

-- Configuring incomplete, errors occurred!

To manually install CMake 2.8 on Redhat/CentOS systems use the sources and follow those instructions:

# Install dependencies
yum install ncurses-devel gcc gcc-c++ make

# Get the sources
cd /usr/local/
tar xzf cmake-
cd cmake-

# Compile and install the sources
make install

# clean the env
cd /usr/local
rm -rf cmake- cmake-

# adding cmake to the PATH 
echo "PATH=/usr/local/bin/:\$PATH" > /etc/profile.d/ 
source /etc/profile

Install PyFaup Python Module

If you receive an error stating "ImportError: No module named 'pyfaup'", perform the following:

  1. Change to directory:
  1. Run:
python install


Why do I receive the error “ cannot open shared object file” when trying to run faup?

If you get a shared library loading error similar to the following when trying to run faup, its probably due to your platform doesn't include the /usr/local/lib shared library directory by default (ex: Ubuntu/Debian) or the directory where faup has its shared library installed:

$ faup
faup: error while loading shared libraries: cannot open shared object file: No such file or director

A good way to see which shared libraries are loaded by faup is by using the ldd command:

$ ldd /usr/local/bin/faup =>  (0x00007fff89735000) => not found => /lib/x86_64-linux-gnu/ (0x00007f55a6082000)
	/lib64/ (0x00007f55a641a000)

To update the faup shared library path, you can use the ldconfig command. For example if faup libraries are installed in /usr/local/lib, you can add the path as follows:

$ echo '/usr/local/lib' | sudo tee -a /etc/
$ ldconfig
$ ldd /usr/local/bin/faup =>  (0x00007fff550d5000) => /usr/local/lib/ (0x00007f41f9102000) => /lib/x86_64-linux-gnu/ (0x00007f41f8d78000)
	/lib64/ (0x00007f41f9317000)