URLPattern

open class URLPattern(input: String, baseURL: String, options: URLPatternOptions = definedExternally)(source)

The URLPattern interface of the URL Pattern API matches URLs or parts of URLs against a pattern.

MDN Reference

Constructors

Link copied to clipboard
constructor(input: String, baseURL: String, options: URLPatternOptions = definedExternally)
constructor(input: URLPatternInit, baseURL: String, options: URLPatternOptions = definedExternally)
constructor(input: String, baseURL: URL, options: URLPatternOptions = definedExternally)
constructor(input: URLPatternInit, baseURL: URL, options: URLPatternOptions = definedExternally)
constructor(input: String = definedExternally, options: URLPatternOptions = definedExternally)
constructor(input: URLPatternInit, options: URLPatternOptions = definedExternally)

Properties

Link copied to clipboard

The hash read-only property of the URLPattern interface is a string containing the pattern used to match the fragment part of a URL.

Link copied to clipboard

The hasRegExpGroups read-only property of the URLPattern interface is a boolean indicating whether or not any of the URLPattern components contain regular expression capturing groups.

Link copied to clipboard

The hostname read-only property of the URLPattern interface is a string containing the pattern used to match the hostname part of a URL.

Link copied to clipboard

The password read-only property of the URLPattern interface is a string containing the pattern used to match the password part of a URL.

Link copied to clipboard

The pathname read-only property of the URLPattern interface is a string containing the pattern used to match the pathname part of a URL.

Link copied to clipboard

The port read-only property of the URLPattern interface is a string containing the pattern used to match the port part of a URL.

Link copied to clipboard

The protocol read-only property of the URLPattern interface is a string containing the pattern used to match the protocol part of a URL.

Link copied to clipboard

The search read-only property of the URLPattern interface is a string containing the pattern used to match the search part of a URL.

Link copied to clipboard

The username read-only property of the URLPattern interface is a string containing the pattern used to match the username part of a URL.

Functions

Link copied to clipboard
fun exec(input: String = definedExternally, baseURL: String = definedExternally): URLPatternResult?

The exec() method of the URLPattern interface takes a URL or object of URL parts, and returns either an object containing the results of matching the URL to the pattern, or null if the URL does not match the pattern.

fun exec(input: String = definedExternally, baseURL: URL): URLPatternResult?
fun exec(input: URLPatternInit, baseURL: String = definedExternally): URLPatternResult?
fun exec(input: URLPatternInit, baseURL: URL): URLPatternResult?
Link copied to clipboard
fun test(input: String = definedExternally, baseURL: String = definedExternally): Boolean

The test() method of the URLPattern interface takes a URL string or object of URL parts, and returns a boolean indicating if the given input matches the current pattern.

fun test(input: String = definedExternally, baseURL: URL): Boolean
fun test(input: URLPatternInit, baseURL: String = definedExternally): Boolean
fun test(input: URLPatternInit, baseURL: URL): Boolean