Yo.utils.matchURL

Use this function to test how Yottaa matches the URL you specify to the source you specify. The function attempts to match using a "contains" operator and a regex match.

Prerequisites

The following command to load the appropriate version of the Rapid+JS Library must precede the use of this function on the page. Specify your own site key:

<script src="https://rapid-cdn.yottaa.com/rapid/lib/sitekey.js"></script>

Syntax

Yo.utils.matchURL(url, src)

Returns

Boolean: True|False

Parameters

Parameter

Description

url

String in single quotation marks. The URL whose match you are testing.

src

The source to which you are comparing the URL.

Format:

Specify a string in single quotation marks to evaluate a possible CONTAINS match.

Specify a regular expression enclosed in forward slashes to evaluate a possible regex match.

Examples

Each of the following examples compares the same URL to a different source, and shows whether the function would return True or False.

/**  
*  Comparisons using CONTAINS operator. These three examples return
*    true, true, and false respectively. 
*/
Yo.utils.matchUrl('https://testing.com/bob.js', 'bob');
Yo.utils.matchUrl('https://testing.com/bob.js', ('https://testing.com/bob.js');
Yo.utils.matchUrl(('https://testing.com/bob.js', 'jim');
/** 
*  Comparisons using regular expressions. These two examples return true 
*    and false respectively. 
*/
Yo.utils.matchUrl(('https://testing.com/bob.js', /bob\.js/);
Yo.utils.matchUrl(('https://testing.com/bob.js', /jim\.js/);