-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer_test.go
More file actions
34 lines (28 loc) · 855 Bytes
/
Copy pathtokenizer_test.go
File metadata and controls
34 lines (28 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package urlpattern_test
import (
"testing"
"time"
"github.com/dunglas/go-urlpattern"
)
// Regression: a pattern pathname ending with a trailing backslash used to
// hang the strict tokenizer because the escape-at-end branch swallowed the
// returned error instead of propagating it, leaving the tokenizer index
// unchanged and causing an infinite loop.
func TestTrailingBackslashDoesNotHang(t *testing.T) {
pathname := "/foo\\"
init := &urlpattern.URLPatternInit{Pathname: &pathname}
done := make(chan struct{})
var newErr error
go func() {
defer close(done)
_, newErr = init.New(nil)
}()
select {
case <-done:
case <-time.After(2 * time.Second):
t.Fatal("URLPatternInit.New hung on pathname with trailing backslash")
}
if newErr == nil {
t.Fatal("expected an error for a pathname ending with a lone backslash, got nil")
}
}