Difference between revisions of "CR.URL"

From Market Ruler Help
Jump to: navigation, search
(Created page with "The '''__CR.URL''' function is a JavaScript function that parses the current URL. It returns a newly created URL object representing the URL defined by the parameters. =...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
When you call __CR.URL() it parses the current URL and the following structure is returned (data is included as part of this example).
 
When you call __CR.URL() it parses the current URL and the following structure is returned (data is included as part of this example).
    {protocol: "https", host: "addresslock.com", path: "/", hash: "", query: "", …}
 
  
*'''''protocol''''': indicates which protocol the browser must use; typically for websites, it is "http" or "https"(its secured version).
+
<nowiki>{
 +
    protocol: "https",
 +
    host: "addresslock.com",
 +
    path: "/",
 +
    hash: "",
 +
    query: "",
 +
    url: https://addresslock.com/",
 +
    queryParams: {},
 +
    queryparams: {}
 +
}</nowiki>
  
*'''''host''''': returns the current domain; indicates which web server is being requested.
+
* '''''protocol''''': indicates which protocol the browser must use; typically for websites, it is "http" or "https" (a web page which is secured between your browser and the server).  
  
*'''''path''''': the path to the resource, starts with "/".
+
* '''''host''''': returns the current domain; indicates which web server is being requested.
  
*'''''query''''': starts with "?", indicates parameters provided to the web server; parameters are listed in key/value pairs separated by the "&" symbol.
+
* '''''path''''': the path to the resource, starts with "/".
  
*'''''hash''''': anchor or fragment identifier, begins with "#"; it is an optional part of a URL that gives the browser directions to content at a "bookmarked" spot.
+
* '''''query''''': starts with "?", indicates parameters provided to the web server; parameters are listed in key/value pairs (using the "=" symbol) and then separated by the "&" symbol.
  
*'''''port''''': indicated by ":" and a number. It is the technical 'gate' used to access the resources on the web server. Port is usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP and 443 for HTTPS).
+
* '''''hash''''': anchor or fragment identifier, begins with "#"; it is an optional part of a URL that gives the browser directions to content at a "bookmarked" spot.
  
Note the changes that occur when you update query parameters in the following example using [https://addresslock.com addresslock.com]:
+
* '''''port''''': indicated by ":" and a number. It is the technical 'gate' used to access the resources on the web server. Port is usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP and 443 for [[HTTPS]]).
  
*For the sample page, [https://addresslock.com addresslock.com]
+
* '''''url''''': The URL which was passed in, but normalized.
  
    [[File:addresslock.png]]
+
* '''''queryParams''''': Always an object which represents the values of the query string, parsed, case sensitive. Values are URL decoded.
  
*Sample page with query parameters:  [https://addresslock.com/?test=123&Test=123 addresslock.com/?test=123&Test=123]
+
* '''''queryparams''''': Always an object which represents the values of the query string, parsed, case-sensitive. Values are URL decoded. Duplicate values override based on order in the string.
  
    [[File:addresslockquery.png]]
+
Note the changes that occur when you update query parameters in the following example using [https://addresslock.com addresslock.com]:
  
*Sample page with hash: [https://addresslock.com/#hash addresslock.com/#hash]
+
* For the sample page: [https://addresslock.com addresslock.com]
  
    [[File:addresslockhash.png]]
+
<nowiki>> __CR.URL()
 +
{"protocol":"https","host":"addresslock.com","path":"/","hash":"","query":"","port":443,"url":"https://addresslock.com/","queryparams":{}}</nowiki>
  
 +
* Sample page with query parameters:  [https://addresslock.com/?test=123&Test=123 addresslock.com/?test=123&Test=123]
  
 +
<nowiki>> __CR.URL()
 +
{"protocol":"https","host":"addresslock.com","path":"/","hash":"","query":"test=abc&Test=123","port":443,"url":"https://addresslock.com/?test=abc&Test=123","queryParams":{"test":"abc","Test":"123"},"queryparams":{"test":"123"}}</nowiki>
 +
 +
* Sample page with hash:  [https://addresslock.com/#hash addresslock.com/#hash]
 +
 +
<nowiki>> __CR.URL()
 +
{"protocol":"https","host":"addresslock.com","path":"/","hash":"hash","query":"","port":443,"url":"https://addresslock.com/#hash","queryparams":{}}</nowiki>
  
 
== See also ==
 
== See also ==
Line 39: Line 56:
 
* [[:Glossary:Parse|Parse]]
 
* [[:Glossary:Parse|Parse]]
  
 
+
[[Category:ConversionRuler]]
Category:ConversionRuler]]
+
[[Category:ConversionRuler JavaScript Functions]]
Category:ConversionRuler JavaScript Functions]]
 

Latest revision as of 13:18, 2 July 2020

The __CR.URL function is a JavaScript function that parses the current URL. It returns a newly created URL object representing the URL defined by the parameters.

Using __CR.URL()

When you call __CR.URL() it parses the current URL and the following structure is returned (data is included as part of this example).

{
     protocol: "https",
     host: "addresslock.com",
     path: "/",
     hash: "",
     query: "",
     url: https://addresslock.com/",
     queryParams: {},
     queryparams: {}
 }
  • protocol: indicates which protocol the browser must use; typically for websites, it is "http" or "https" (a web page which is secured between your browser and the server).
  • host: returns the current domain; indicates which web server is being requested.
  • path: the path to the resource, starts with "/".
  • query: starts with "?", indicates parameters provided to the web server; parameters are listed in key/value pairs (using the "=" symbol) and then separated by the "&" symbol.
  • hash: anchor or fragment identifier, begins with "#"; it is an optional part of a URL that gives the browser directions to content at a "bookmarked" spot.
  • port: indicated by ":" and a number. It is the technical 'gate' used to access the resources on the web server. Port is usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP and 443 for HTTPS).
  • url: The URL which was passed in, but normalized.
  • queryParams: Always an object which represents the values of the query string, parsed, case sensitive. Values are URL decoded.
  • queryparams: Always an object which represents the values of the query string, parsed, case-sensitive. Values are URL decoded. Duplicate values override based on order in the string.

Note the changes that occur when you update query parameters in the following example using addresslock.com:

> __CR.URL()
 {"protocol":"https","host":"addresslock.com","path":"/","hash":"","query":"","port":443,"url":"https://addresslock.com/","queryparams":{}}
> __CR.URL()
 {"protocol":"https","host":"addresslock.com","path":"/","hash":"","query":"test=abc&Test=123","port":443,"url":"https://addresslock.com/?test=abc&Test=123","queryParams":{"test":"abc","Test":"123"},"queryparams":{"test":"123"}}
> __CR.URL()
 {"protocol":"https","host":"addresslock.com","path":"/","hash":"hash","query":"","port":443,"url":"https://addresslock.com/#hash","queryparams":{}}

See also