Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TemplateURL

Hierarchy

  • URL
    • TemplateURL

Index

Constructors

constructor

  • Parameters

    • url: string

      -

    • base: string

      -

    • Optional parameters: undefined | { origin?: undefined | string; pathParams?: PathParameters; queryParams?: QueryParameters }

    Returns TemplateURL

Properties

hash

hash: string

host

host: string

hostname

hostname: string

href

href: string

Readonly origin

origin: string

password

password: string

pathname

pathname: string

port

port: string

protocol

protocol: string

search

search: string

Readonly searchParams

searchParams: URLSearchParams

username

username: string

Static URL

URL: typeof globalThis extends { URL: infer URL; onmessage: any } ? URL : typeof _URL

URL class is a global reference for require('url').URL https://nodejs.org/api/url.html#the-whatwg-url-api

since

v10.0.0

Methods

addQueryParams

  • Add append an object literal of query parameters to the URL object. SCAPI expects Arrays to be comma separated where { a: ["1", "2"] } becomes ?a=1,2. The 'refine' query parameter is an exception, where SCAPI expects the the "repeat" convention where { refine: ["1", "2"] } becomes "?refine=1&refine=2"

    Parameters

    Returns void

replaceOrigin

  • replaceOrigin(newOriginString: string): void
  • Replace the origin (protocol/host) portion of the URL with a new origin. The path portion is retained and concatenated with any path included in the new origin. Thee primary use of this function is to use a proxy.

    Parameters

    Returns void

toJSON

  • toJSON(): string
  • Returns string

toString

  • toString(): string
  • Returns string

Static createObjectURL

  • createObjectURL(blob: Blob): string
  • Creates a 'blob:nodedata:...' URL string that represents the given Blob object and can be used to retrieve the Blob later.

    const {
      Blob,
      resolveObjectURL,
    } = require('buffer');
    
    const blob = new Blob(['hello']);
    const id = URL.createObjectURL(blob);
    
    // later...
    
    const otherBlob = resolveObjectURL(id);
    console.log(otherBlob.size);

    The data stored by the registered Blob will be retained in memory untilURL.revokeObjectURL() is called to remove it.

    Blob objects are registered within the current thread. If using Worker Threads, Blob objects registered within one Worker will not be available to other workers or the main thread.

    since

    v16.7.0

    experimental

    Parameters

    • blob: Blob

    Returns string

Static renderTemplateUri

  • renderTemplateUri(template: string, parameters?: PathParameters): string
  • Replace bracketed URL template parameters with values from parameters object

    Parameters

    • template: string

      The URL template string to make substitutions in

    • Optional parameters: PathParameters

      The object literal that provides the values to substitute

    Returns string

    String URL with substitutions made

Static revokeObjectURL

  • revokeObjectURL(objectUrl: string): void
  • Removes the stored Blob identified by the given ID. Attempting to revoke a ID that isn’t registered will silently fail.

    since

    v16.7.0

    experimental

    Parameters

    • objectUrl: string

    Returns void

Generated using TypeDoc