Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netzo/deno.d.ts>URLPattern#exec

SDK for Netzo, the open Web platform to unify IoT devices, applications and services.
Go to Latest
method URLPattern.prototype.exec
import { URLPattern } from "https://deno.land/x/netzo@v0.1.10/deno.d.ts";

Match the given input against the stored pattern.

The input can either be provided as a url string (with an optional base), or as individual components in the form of an object.

const pattern = new URLPattern("https://example.com/books/:id");

// Match a url string.
let match = pattern.exec("https://example.com/books/123");
console.log(match.pathname.groups.id); // 123

// Match a relative url with a base.
match = pattern.exec("/books/123", "https://example.com");
console.log(match.pathname.groups.id); // 123

// Match an object of url components.
match = pattern.exec({ pathname: "/books/123" });
console.log(match.pathname.groups.id); // 123

Parameters

optional
baseURL: string