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

[BUG] Asterisk and intersecting fragments not working as expected #61

Open
naughtyfox opened this issue Aug 1, 2023 · 1 comment
Open

Comments

@naughtyfox
Copy link

naughtyfox commented Aug 1, 2023

HI, all!
I got the following code:

package main

import (
	"log"

	"github.com/gobwas/glob"
)

func main() {
	pattern := "start*art"
	gl := glob.MustCompile(pattern)

	s := "start"
	log.Printf("Result: %v", gl.Match(s)) 
}

Which results in:

$ ./main
2023/08/01 16:20:08 Result: true

I expect it to be false. Is this a bug?

@naughtyfox
Copy link
Author

I checked it against filepath.Match function:

package main

import (
	"log"
	"path/filepath"

	"github.com/gobwas/glob"
)

func main() {
	pattern := "start*art"
	gl := glob.MustCompile(pattern)

	s := "start"
	log.Printf("glob result: %v", gl.Match(s))

	matched, err := filepath.Match(pattern, s)
	if err != nil {
		log.Fatalf("failed to match: %v", err)
	}

	log.Printf("filepath.Match result: %v", matched)
}

Result:

$ ./main
2023/08/01 16:58:00 glob result: true
2023/08/01 16:58:00 filepath.Match result: false

It seems like a bug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant