Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Uri

It is a wrapper over the outdated and non-intuitive Node.js URL.

Hierarchy

Index

Constructors

constructor

  • new Uri(uri: string): Uri

Properties

query

query: Query = new Query()

Query part of the uri.

Accessors

absoluteUri

  • get absoluteUri(): string

auth

  • get auth(): string | null
  • set auth(value: string | null): void
  • Auth part of the uri.

    Can be 'username' or 'username:password'.

    Returns string | null

  • Auth part of the uri.

    Can be 'username' or 'username:password'.

    throws

    when setting incorrect auth.

    Parameters

    • value: string | null

    Returns void

fragment

  • get fragment(): string | null
  • set fragment(value: string | null): void
  • Fragment part of the uri (url encoded).

    const uri = new Uri('http://fakedomain.com/path');
    uri.fragment = 'test';
    uri.toString(); // http://fakedomain.com/path/#test
    // or
    uri.fragment = '#test';
    uri.toString(); // http://fakedomain.com/path/#test

    Returns string | null

  • Fragment part of the uri (url encoded).

    const uri = new Uri('http://fakedomain.com/path');
    uri.fragment = 'test';
    uri.toString(); // http://fakedomain.com/path/#test
    // or
    uri.fragment = '#test';
    uri.toString(); // http://fakedomain.com/path/#test

    Parameters

    • value: string | null

    Returns void

host

  • get host(): string

hostname

  • get hostname(): string
  • set hostname(value: string): void
  • Hostname part of the uri.

    Returns string

  • Hostname part of the uri.

    throws

    when setting empty

    Parameters

    • value: string

    Returns void

path

  • get path(): string
  • set path(value: string): void

port

  • get port(): number | null
  • set port(value: number | null): void

relativeUri

  • get relativeUri(): string

scheme

Methods

toString

  • toString(): string

Static merge

  • Create new Uri object with joined path and query params.

    warning

    The fragment is taken from the relativeUri!

    const uri = new Uri('http://host.com/users?k1=v1#oldFragment');
    const relativeUri = new RelativeUri('/15?k2=v2#newFragment');
    const newUri = Uri.merge(uri, relativeUri);
    newUri.toString(); // http://host.com/users/15/?k1=v1&k2=v2#newFragment

    Parameters

    Returns Uri

Generated using TypeDoc