Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support glob.match without delimiters #4923 #4933

Merged
merged 8 commits into from
Jul 25, 2022
2 changes: 1 addition & 1 deletion docs/content/policy-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ The following table shows examples of how ``glob.match`` works:
| -------- | ---------- | ----------- |
| ``output := glob.match("*.github.com", [], "api.github.com")`` | ``true`` | A glob with the default ``["."]`` delimiter. |
| ``output := glob.match("*.github.com", [], "api.cdn.github.com")`` | ``false`` | A glob with the default ``["."]`` delimiter. |
| ``output := glob.match("*.github.com", null, "api.cdn.github.com")`` | ``true`` | A glob without delimiter. |
| ``output := glob.match("*hub.com", null, "api.cdn.github.com")`` | ``true`` | A glob without delimiter. |
| ``output := glob.match("*:github:com", [":"], "api:github:com")`` | ``true`` | A glob with delimiters ``[":"]``. |
| ``output := glob.match("api.**.com", [], "api.github.com")`` | ``true`` | A super glob. |
| ``output := glob.match("api.**.com", [], "api.cdn.github.com")`` | ``true`` | A super glob. |
Expand Down
2 changes: 2 additions & 0 deletions topdown/glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func builtinGlobMatch(a, b, c ast.Value) (ast.Value, error) {
if len(delimiters) == 0 {
delimiters = []rune{'.'}
}
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this isn't what I meant -- if it's not null and not an array, it might be something like

  • 123
  • true
  • "foo"
    i.e. some other type of Value. We should not start to silently ignore that bad input, so let's return some sort of OperandError here, please.

delimiters = []rune{}
}
match, err := builtins.StringOperand(c, 3)
if err != nil {
Expand Down