externalPseudoUrl
Index
Constructors
externalconstructor
Parameters
externalpurl: string | RegExp
A pseudo-URL string or a regular expression object. Using a
RegExp
instance enables more granular control, such as making the matching case-sensitive.
Returns PseudoUrl
Properties
externalreadonlyregex
Methods
externalmatches
Determines whether a URL matches this pseudo-URL pattern.
Parameters
externalurl: string
Returns boolean
Represents a pseudo-URL (PURL) - a URL pattern used to find the matching URLs on a page or html document.
A PURL is simply a URL with special directives enclosed in
[]
brackets. Currently, the only supported directive is[RegExp]
, which defines a JavaScript-style regular expression to match against the URL.The
PseudoUrl
class can be constructed either using a pseudo-URL string or a regular expression (an instance of theRegExp
object). With a pseudo-URL string, the matching is always case-insensitive. If you need case-sensitive matching, use an appropriateRegExp
object.Internally,
PseudoUrl
class is usingpurlToRegExp
function which parses the provided PURL and converts it to an instance of theRegExp
object (in case it's not).For example, a PURL
http://www.example.com/pages/[(\w|-)*]
will match all of the following URLs:http://www.example.com/pages/
http://www.example.com/pages/my-awesome-page
http://www.example.com/pages/something
Be careful to correctly escape special characters in the pseudo-URL string. If either
[
or]
is part of the normal query string, it must be encoded as[\x5B]
or[\x5D]
, respectively. For example, the following PURL:will match the URL:
If the regular expression in the pseudo-URL contains a backslash character (), you need to escape it with another back backslash, as shown in the example below.
Example usage: