FCF 2.0 development in progress...
> > > > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

constructor() method from fcf.RouteInfo class

constructor()
constructor(string a_url, string a_relativeMode = "relative", object a_postArgs = {})
constructor(fcf.RouteInfo a_routeInfo, string a_relativeMode = "relative", object a_postArgs = {})

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Class constructor

Arguments

string a_url
- URL or URI address

fcf.RouteInfo a_routeInfo
- Object with initial data

string a_relativeMode
- Defines the behavior of the function if the URL is given as a relative path.

The parameter can take one of three values

  • "relative" - A relative path is passed as relative. Example:

  • "root" - Relative paths are interpreted as a path specified from the root. Example:

  • "server" - The first element of a relative path is interpreted as the name of the server. Example:

Example: Relative mode

console.log(new fcf.RouteInfo("part/item?query=1"))

Output:

{ "url": "part/item?query=1", "referer": "part/item", "uri": "part/item", "urlArgs": { "query": 1 }, "urlArgsRaw": { "query": "1" }, "urlArgsStr": "query=1", "postArgs": {}, "postArgsRaw": {}, "args": { "query": 1 }, "argsRaw": { "query": "1" }, "subUri": "", "anchor": "", "server": "", "protocol": "" }

Example: Root mode

console.log(new fcf.RouteInfo("part/item?query=1", "root"))

Output:

{ "url": "/part/item?query=1", "referer": "/part/item", "uri": "/part/item", "urlArgs": { "query": 1 }, "urlArgsRaw": { "query": "1" }, "urlArgsStr": "query=1", "postArgs": {}, "postArgsRaw": {}, "args": { "query": 1 }, "argsRaw": { "query": "1" }, "subUri": "", "anchor": "", "server": "", "protocol": "" }

Example: Server mode

console.log(new fcf.RouteInfo("part.org:8080/item?query=1", "server"))

Output:

{ "url": "http://part.org:8080/item?query=1", "referer": "http://part.org:8080/item", "uri": "/item", "urlArgs": { "query": 1 }, "urlArgsRaw": { "query": "1" }, "urlArgsStr": "query=1", "postArgs": {}, "postArgsRaw": {}, "args": { "query": 1 }, "argsRaw": { "query": "1" }, "subUri": "", "anchor": "", "server": "part.org", "port": 8080, "protocol": "http" }

object a_postArgs = {}
- Additional arguments passed via POST request