RFC 3986 URI type.

A data reader literal #uri is available for a convenient URI creation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(ns foo.baz
  (:api dunaj)
  (:require [dunaj.uri :refer [uri relativize resolve]]))

(uri :http "example.com" 338)
;;=> #uri "http://example.com:338"

#uri "http://example.com/foo/bar"
;;=> #uri "http://example.com/foo/bar"

(:query (uri "http://example.com/foo/bar?q=baz&r=qux"))
;;=> "q=baz&r=qux"

(:host (uri "http://example.com/foo/bar"))
;;=> "example.com"

(relativize (uri "http://example.com/foo")
            (uri "http://example.com/foo/d"))
;;=> #uri "d"

(resolve (uri "http://example.com/foo/") "../d")
;;=> #uri "http://example.com/d"

Uri

Available since version 1.0 (view source)

TYPE

A URI type.

Use dunaj.coll/get to obtains parts of the URI. Following keys are supported: :scheme, :scheme-specific-part, :authority, :user-info, :host, :port, :path, :query and :fragment.

See also: uri?, uri

absolute?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (absolute? uri)

Type signature:
  • (Uri) → Boolean+

Returns true if uri has a scheme, otherwise returns false.

See also: opaque?

normalize

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (normalize uri)

Type signature:
  • (Uri) → Uri

Returns normalized uri.

See also: relativize, resolve

opaque?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (opaque? uri)

Type signature:
  • (Uri) → Boolean+

Returns true if uri is absolute and its scheme specific part does not begin with slash /.

See also: absolute?

relativize

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (relativize root uri)

Type signature:
  • (Uri ⨯ Uri) → Uri

Returns relativized uri againsts root uri.

See also: normalize, resolve

resolve

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (resolve root val)

Type signature:
  • (Uri ⨯ (U String+ Uri)) → Uri

Returns uri created by resolving val against root uri. Calls uri on val.

See also: normalize, relativize

uri

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (uri val)

  • (uri scheme host port)

Type signatures:
  • ((U String+ Uri)) → Uri

  • (INamed ⨯ String+ ⨯ Integer+) → Uri

Returns URI from its canonical string representation val. or from scheme, host and port. Returns val if it already is a URI object.

See also: uri?

uri?

Available since version 1.0 (view source)

Usage:
  • (uri? x)

Type signature: Predicate

Returns true if object x is an instance of Uri type, false otherwise.

See also: Uri, uri