blob: 2fa9c452f52d275d482c00d0f2ea4f9f62b0146b [file] [log] [blame]
Avi Drissman505076bc2022-10-06 21:15:301// Copyright 2020 The Chromium Authors
Ben Kelly36f7ba3e2020-11-24 19:48:462// Copyright 2014 Blake Embrey ([email protected])
3// Use of this source code is governed by an MIT-style license that can be
4// found in the LICENSE file or at https://opensource.org/licenses/MIT.
5
6#ifndef THIRD_PARTY_LIBURLPATTERN_OPTIONS_H_
7#define THIRD_PARTY_LIBURLPATTERN_OPTIONS_H_
8
9#include <string>
10#include "base/component_export.h"
11
12namespace liburlpattern {
13
14// A structure that may be provided to the Parse() function to control matching
15// behavior. This corresponds to a union of the two path-to-regexp structures
16// at:
17//
18// https://github.com/pillarjs/path-to-regexp/blob/125c43e6481f68cc771a5af22b914acdb8c5ba1f/src/index.ts#L126-L135
19//
20// and:
21//
22// https://github.com/pillarjs/path-to-regexp/blob/125c43e6481f68cc771a5af22b914acdb8c5ba1f/src/index.ts#L498-L527
23struct COMPONENT_EXPORT(LIBURLPATTERN) Options {
24 // |delimiter_list| contains a list of characters that are considered segment
25 // separators when performing a kSegmentWildcard. This is the behavior you
26 // get when you specify a name `:foo` without a custom regular expression.
27 // These characters are also optionally permitted at the end of an input
28 // string when |strict| is false.
29 std::string delimiter_list = "/#?";
30
31 // |prefix_list| contains a list of characters to automatically treat as a
32 // prefix when they appear before a kName or kRegex Token; e.g. "/:foo",
33 // includes the leading "/" as the prefix for the "foo" named group by
34 // default.
35 std::string prefix_list = "./";
36
37 // True if matching should be case sensitive.
38 bool sensitive = false;
39
40 // When true matching will not permit an optional trailing delimiter. For
41 // example, when false a pattern "/foo" will match the string "/foo/". The
42 // allowed trailing delimiter characters are contained in |delimiter_list|.
43 bool strict = false;
44
45 // When true requires matching to the end of the input string.
46 bool end = true;
47
48 // When true requires matching to begin at the start of the input string.
49 bool start = true;
50
51 // A list of characters that can also signal the "end" of an input string.
52 std::string ends_with;
53
54 // Note, we do not include an |encode| option here like path-to-regexp. This
55 // library requires that calling code percent encode UTF8 as ascii before
56 // calling Parse().
57};
58
59} // namespace liburlpattern
60
61#endif // THIRD_PARTY_LIBURLPATTERN_OPTIONS_H_