Forum

Methodology

Toolbox

Platform

Community

desktop
touch-pad
touch-phone

uri

This block provides an object with a set of methods for decoding a URI-encoded string.

Overview

Properties and methods of the object

Name Return type Description
decodeURI(str {String}) String Decodes a URI.
decodeURIComponent(str {String}) String Decodes a URI component.

Elements of the block

Element Usage Description
querystring JS This element provides an object with a set of methods for working with a URI query string. It decodes the string from URI format.

Properties and methods of the object

Element Name Returned value Description
querystring parse(str {String}) Object Creates an object using the query parameters from the address bar.
stringify(obj {Object}) String Creates a query string based on the object properties.

Public block technologies

The block is implemented in:

  • vanilla.js

Properties and methods of the object

Both of these methods function as wrappers for the standard JavaScript methods decodeURI and decodeURIComponent.

As they execute, the methods check whether the passed string is in UTF-8 format. If not, they generate an error.

decodeURI method

Decodes a URI. This method is identical to the standard JavaScript method decodeURI, but it supports Cyrillic encoding CP-1251.

Accepted arguments:

  • str {String} – A string with escape sequences. Required argument.

Return value: String. If escape sequences are not found in the string, the method returns the string without any changes.

Example:

modules.require('uri', function(uri){
    uri.decodeURI("https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
    // "https://developer.mozilla.org/ru/docs/JavaScript_Shells"
})

decodeURIComponent method

Decodes a URI component. This method is identical to the standard JavaScript method decodeURIComponent, but it supports Cyrillic encoding CP-1251.

Accepted arguments:

  • str {String} – A string with escape sequences. Required argument.

Return value: String. If escape sequences are not found in the string, the method returns the string without any changes.

Example:

modules.require('uri', function(uri){
    uri.decodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
    // "JavaScript_Shells"
})

Elements of the block

querystring element

This element provides an object with a set of methods for working with a URI query string.

Properties and methods of the object

parse method

Creates an object using the parameters from a URI query string.

Accepted arguments:

  • str {String} – A string with parameters as key-value pairs. The = symbol separates a key from its value. Pairs are separated by the & symbol. During parsing, keys and values are decoded from URI format. Required argument.

Return value: Object. The object created from the parameters in the address bar.

stringify method

Creates a URI query string from an object.

Accepted arguments:

  • obj {Object} – The object to create the string from. Required argument.

Return value: String. Property names are separated from values by the = symbol, and the & symbol separates pairs in the string.

Module uri

A set of helpers to work with URI

Object methods:

decodeURI(str):String
description
Decodes URI string
parameters
str
String
decodeURIComponent(str):String
description
Decodes URI component string
parameters
str
String

uri__querystring

A set of helpers to work with query strings

Object methods:

parse(str):Object
description
Parse a query string to an object
parameters
str
String
stringify(obj):String
description
Serialize an object to a query string
parameters
obj
Object