chromium/third_party/blink/renderer/core/url_pattern/url_pattern.idl

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

typedef (USVString or URLPatternInit) URLPatternInput;
typedef (USVString or URLPatternInit or URLPattern) URLPatternCompatible;

enum URLPatternComponent { "protocol", "username", "password", "hostname",
                           "port", "pathname", "search", "hash" };

// https://wicg.github.io/urlpattern/
[
  Exposed=(Window,Worker)
] interface URLPattern {
  [RaisesException, CallWith=Isolate, Measure]
  constructor(URLPatternInput input, USVString baseURL, optional URLPatternOptions options = {});

  [RaisesException, CallWith=Isolate, Measure]
  constructor(optional URLPatternInput input = {}, optional URLPatternOptions options = {});

  [RaisesException, CallWith=ScriptState, Measure]
  boolean test(optional URLPatternInput input = {}, optional USVString baseURL);

  [RaisesException, CallWith=ScriptState, Measure]
  URLPatternResult? exec(optional URLPatternInput input = {}, optional USVString baseURL);

  readonly attribute USVString protocol;
  readonly attribute USVString username;
  readonly attribute USVString password;
  readonly attribute USVString hostname;
  readonly attribute USVString port;
  readonly attribute USVString pathname;
  readonly attribute USVString search;
  readonly attribute USVString hash;

  readonly attribute boolean hasRegExpGroups;

  [RuntimeEnabled=URLPatternCompareComponent, Measure]
  static short compareComponent(URLPatternComponent component,
                                URLPattern left, URLPattern right);
};