mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
fix!: Fix glob.match behavior in presence of : (#390)
glob.match("api://*/appId", null, "api://foo.com/appId") wasn't
being handled correctly. Switch to globset crate.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
757edcc8fb
commit
f46ab5b697
@@ -9,8 +9,7 @@ use crate::value::Value;
|
||||
use crate::*;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
//use glob::{Pattern, MatchOptions};
|
||||
use wax::{Glob, Pattern};
|
||||
use globset::{GlobBuilder, GlobMatcher};
|
||||
|
||||
pub fn register(m: &mut builtins::BuiltinsMap<&'static str, builtins::BuiltinFcn>) {
|
||||
m.insert("glob.match", (glob_match, 3));
|
||||
@@ -50,8 +49,12 @@ fn make_delimiters_unix_style(s: &str, delimiters: &[char]) -> Result<String> {
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
fn make_glob<'a>(pattern: &'a str, span: &'a Span) -> Result<Glob<'a>> {
|
||||
Glob::new(pattern).or_else(|_| bail!(span.error("invalid glob")))
|
||||
fn make_glob(pattern: &str, span: &Span) -> Result<GlobMatcher> {
|
||||
Ok(GlobBuilder::new(pattern)
|
||||
.literal_separator(true)
|
||||
.build()
|
||||
.or_else(|_| bail!(span.error("invalid glob")))?
|
||||
.compile_matcher())
|
||||
}
|
||||
|
||||
fn glob_match(span: &Span, params: &[Ref<Expr>], args: &[Value], _strict: bool) -> Result<Value> {
|
||||
|
||||
@@ -292,6 +292,7 @@ fn yaml_test_impl(file: &str) -> Result<()> {
|
||||
"compare.yaml",
|
||||
"diff.yaml",
|
||||
"format.yaml",
|
||||
"globmatch.yaml",
|
||||
"now_ns.yaml",
|
||||
"parse_duration_ns.yaml",
|
||||
"parse_ns.yaml",
|
||||
|
||||
Reference in New Issue
Block a user