capturl-contextual


License

License

GroupId

GroupId

fr.davit
ArtifactId

ArtifactId

capturl-contextual_2.12
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

capturl-contextual
capturl-contextual
Project URL

Project URL

https://github.com/RustedBones/capturl
Project Organization

Project Organization

Michel Davit
Source Code Management

Source Code Management

https://github.com/RustedBones/capturl

Download capturl-contextual_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/fr.davit/capturl-contextual_2.12/ -->
<dependency>
    <groupId>fr.davit</groupId>
    <artifactId>capturl-contextual_2.12</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/fr.davit/capturl-contextual_2.12/
implementation 'fr.davit:capturl-contextual_2.12:0.3.0'
// https://jarcasting.com/artifacts/fr.davit/capturl-contextual_2.12/
implementation ("fr.davit:capturl-contextual_2.12:0.3.0")
'fr.davit:capturl-contextual_2.12:jar:0.3.0'
<dependency org="fr.davit" name="capturl-contextual_2.12" rev="0.3.0">
  <artifact name="capturl-contextual_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.davit', module='capturl-contextual_2.12', version='0.3.0')
)
libraryDependencies += "fr.davit" % "capturl-contextual_2.12" % "0.3.0"
[fr.davit/capturl-contextual_2.12 "0.3.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.12
fr.davit : capturl_2.12 jar 0.3.0
com.propensive : contextual-core_2.12 jar 3.0.0

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.2.3

Project Modules

There are no modules declared in this project.

capturl

Continuous Integration Maven Central Software License

Capturl is a Scala/Java library that provide parsers and models to work with Internationalized Resource Identifier aka IRIs.

The implementation is strongly inspired by the great akka-http Uri model with modularity and simplicity in mind.

Setup

Add to your build.sbt:

libraryDependencies += "fr.davit" %% "capturl" % "<version>"

Parsers

All the apply/create methods accepting String input will be validated against RFC 3987 compliant parsers to create the model classes.

Warning: Exception is made for spaces in path, query and fragment which are allowed at the moment (see TODOs)

If you are sure about your input, and want to skip validation for efficiency reason, you can construct the models using the implementation classes. eg:

Scheme("b@d_scheme") // throws a parsing exception
Scheme.Protocol("b@d_scheme") // this is very wrong but will create your scheme

Normalization

Those are the IRI normalization steps:

  • Scheme
    • lower case normalization
  • Hosts
    • NamedHost are lower cased and decoded (punycode)
    • IPv4 and IPv6 are normalized
  • Path
    • collapse current folder
    • collapse parent folder
  • Query
    • spaces are replaced by '+'
  • Iri
    • omit custom port if matches the scheme default port
    • root path is added for absolute / host relative iris
    • default port is hidden
  • General
    • all encoded characters are decoded

IRI string interpolation

Add to your build.sbt:

libraryDependencies += "fr.davit" %% "capturl-contextual" % <version>

This sub module provides compile time string interpolation to create IRIs:

val iri = iri"http://localhost:8080/path?key#identifier"

If iri string is not valid, the scala compiler will notify you:

val iri = iri"http://user{[email protected]/"
[error] Invalid IRI http://user{[email protected]/
[error]     iri"http://user{[email protected]/"
[error]         ^
[error] one error found

TODO

  • provide strict / relax parser mode
  • provide more normalization options
  • support holes in interpolation

capturl-akka-http

Add to your build.sbt:

libraryDependencies += "fr.davit" %% "capturl-akka-http" % <version>

This sub module provides all the necessary implicits in UriConverters to go from an Iri to the akka Uri model.

TODO

  • provide converters for akka-http javadsl model

Versions

Version
0.3.0
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0