gobwas/glob

[BUG] Asterisk and intersecting fragments not working as expected

naughtyfox opened this issue · 1 comments

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?

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...