Interface: UrlAdapter

Oracle® JavaScript Extension Toolkit (JET)
15.1.0

F83698-01

Module:
  • ojcorerouter

QuickNav

Description

A UrlAdapter is used by CoreRouter to read and write router states using the browser URL.


Usage

Signature:

interface UrlAdapter<P extends Record<string, any> = Record<string, any>>

Typescript Import Format
//To use this interface, import as below.
import CoreRouter= require("ojs/ojcorerouter");

//To access this interface in your code,
let myVariable: CoreRouter.UrlAdapter;

For additional information visit:


A UrlAdapter is used by CoreRouter to read and write router states using the browser URL.

Methods

getRoutesForUrl(routePathParams, url) : {Array.<CoreRouter.Route.<P>>}

Build all routes for the given URL. The URL is expected to start with the baseUrl set for this adapter, because it will be subtracted out before routes are built.
Parameters:
Name Type Argument Description
routePathParams {offset: number, pathParams: Array.<string>} <optional>
An optional object that may be passed from the router for the adapter parse the URL with path parameter information. The object will contain the URL segment offset (segments are individual parts of the path) at where the relevant state begins, and the path parameters for that state as an array of strings.

{
  offset: number,
  pathParams: string[]
}

If passed, the adapter should build the state with path parameter values for the given offset and return it within the final array. If not passed, the adapter should build the states from the URL, assuming each segment is a new state.
url string <optional>
Optional value passed to the adapter for the current URL holding the router state. This is only present when the adapter is wrapped inside of UrlParamAdapter (see constructor documentation for details).
Returns:

An array of all states represented in the URL.

Type
Array.<CoreRouter.Route.<P>>

getUrlForRoutes(states) : {string}

Build the URL path for the given routes.
Parameters:
Name Type Description
states Array.<CoreRouter.Route.<P>> The set of states from which the URL will be built.
Returns:

The full URL representative of the given routes

Type
string