All Projects β†’ smola β†’ Galimatias

smola / Galimatias

Licence: mit
galimatias is a URL parsing and normalization library written in Java.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Galimatias

Faup
Fast URL decoder library
Stars: ✭ 159 (+8.9%)
Mutual labels:  url, url-parsing
Hyperlink
πŸ”— Immutable, Pythonic, correct URLs.
Stars: ✭ 198 (+35.62%)
Mutual labels:  url, url-parsing
Tldts
JavaScript Library to work against complex domain names, subdomains and URIs.
Stars: ✭ 151 (+3.42%)
Mutual labels:  url, url-parsing
Scala Uri
Simple scala library for building and parsing URIs
Stars: ✭ 225 (+54.11%)
Mutual labels:  url, url-parsing
Frontexpress
An Express.js-Style router for the front-end
Stars: ✭ 263 (+80.14%)
Mutual labels:  url, url-parsing
Libvmod Querystring
Query-string module for Varnish Cache
Stars: ✭ 85 (-41.78%)
Mutual labels:  url, url-parsing
Furl
🌐 URL parsing and manipulation made easy.
Stars: ✭ 2,152 (+1373.97%)
Mutual labels:  url, url-parsing
uri
A type to represent, query, and manipulate a Uniform Resource Identifier.
Stars: ✭ 16 (-89.04%)
Mutual labels:  url, url-parsing
tall
Promise-based, No-dependency URL unshortner (expander) module for Node.js
Stars: ✭ 56 (-61.64%)
Mutual labels:  url, url-parsing
Universal Url
WHATWG URL for Node & Browser.
Stars: ✭ 20 (-86.3%)
Mutual labels:  url, url-parsing
Uddup
Urls de-duplication tool for better recon.
Stars: ✭ 103 (-29.45%)
Mutual labels:  url, url-parsing
Laravel Short Url
A Laravel package to shorten urls
Stars: ✭ 127 (-13.01%)
Mutual labels:  url
Validator
A tool to validate text inside TextInputLayout
Stars: ✭ 117 (-19.86%)
Mutual labels:  validator
Milkomeda
Spring extend componets which build from experience of bussiness, let developers to develop with Spring Boot as fast as possible.(基于Springη”Ÿζ€ζ‰“ι€ ηš„δΈ€η³»εˆ—ζ₯θ‡ͺδΈšεŠ‘δΈŠηš„εΏ«ι€ŸεΌ€ε‘ζ¨‘ε—ι›†εˆγ€‚οΌ‰
Stars: ✭ 117 (-19.86%)
Mutual labels:  validator
Emailvalidator
PHP Email address validator
Stars: ✭ 10,482 (+7079.45%)
Mutual labels:  validator
Api Query Params
Convert URL query parameters to MongoDB queries
Stars: ✭ 141 (-3.42%)
Mutual labels:  url
Awesome Python Models
A curated list of awesome Python libraries, which implement models, schemas, serializers/deserializers, ODM's/ORM's, Active Records or similar patterns.
Stars: ✭ 124 (-15.07%)
Mutual labels:  validator
Ethereum Staking Guide
Ethereum 2.0 Staking Guides
Stars: ✭ 116 (-20.55%)
Mutual labels:  validator
Finicky
A macOS app for customizing which browser to start
Stars: ✭ 2,026 (+1287.67%)
Mutual labels:  url
Biturl
URL shortener service, powered by Go.
Stars: ✭ 113 (-22.6%)
Mutual labels:  url

galimatias

Build Status Coverage Status

galimatias is a URL parsing and normalization library written in Java.

Design goals

  • Parse URLs as browsers do, optionally enforcing compliance with old standards (i.e. RFC 3986, RFC 2396).
  • Stay as close as possible to WHATWG's URL Standard.
  • Convenient fluent API with immutable URL objects.
  • Interoperable with java.net.URL and java.net.URI.
  • Minimal dependencies.

Gotchas

galimatias is not a generic URI parser. It can parse any URI, but only schemes defined in the URL Standard (i.e. http, https, ftp, ws, wss, gopher, file) will be parsed as hierarchical URIs. For example, in git://github.com/smola/galimatias.git you'll be able to extract scheme (i.e. git) and scheme data (i.e. //github.com/smola/galimatias.git), but not host (i.e. github.com). This is intended. We cannot guarantee that applying a set of generic rules won't break certain kind of URIs, so we do not try with them. I will consider adding further support for other schemes if enough people provides solid use cases and testing. You can check this issue if you are interested.

But, why?

galimatias started out of frustration with java.net.URL and java.net.URI. Both of them are good for basic use cases, but severely broken for others:

  • java.net.URL.equals() is broken.

  • java.net.URI can parse only RFC 2396 URI syntax. java.net.URI will only parse a URI if it's strictly compliant with RFC 2396. Most URLs found in the wild do not comply with any syntax standard, and RFC 2396 is outdated anyway.

  • java.net.URI is not protocol-aware. http://example.com, http://example.com/ and http://example.com:80 are different entities.

  • Manipulation is a pain. I haven't seen any URL manipulation code using java.net.URL or java.net.URI that is simple and concise.

  • Not IDN ready. Java has IDN support with java.net.IDN, but this does not apply to java.net.URL or java.net.URI.

Setup with Maven

galimatias is available at Maven Central. Just add to your pom.xml <dependencies> section:

<dependency>
  <groupId>io.mola.galimatias</groupId>
  <artifactId>galimatias</artifactId>
  <version>0.2.1</version>
</dependency>

Development snapshots are also available at Sonatype OSS Snapshots repository.

Getting started

Parse a URL

// Parse
String urlString = //...
URL url;
try {
  url = URL.parse(urlString);
} catch (GalimatiasParseException ex) {
  // Do something with non-recoverable parsing error
}

Convert to java.net.URL

URL url = //...
java.net.URL javaURL;
try {
  javaURL = url.toJavaURL();
} catch (MalformedURLException ex) {
  // This can happen if scheme is not http, https, ftp, file or jar.
}

Convert to java.net.URI

URL url = //...
java.net.URI javaURI;
try {
  javaURI = url.toJavaURI();
} catch (URISyntaxException ex) {
  // This will happen in rare cases such as "foo://"
}

Parse a URL with strict error handling

You can use a strict error handler that will throw an exception on any invalid URL, even if it's a recovarable error.

URLParsingSettings settings = URLParsingSettings.create()
  .withErrorHandler(StrictErrorHandler.getInstance());
URL url = URL.parse(settings, urlString);

Documentation

Check out the Javadoc.

Contribute

Did you find a bug? Report it on GitHub.

Did you write a patch? Send a pull request.

Something else? Email me at [email protected].

License

Copyright (c) 2013-2014 Santiago M. Mola [email protected]

galimatias is released under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].