| 49 | } |
| 50 | |
| 51 | func TestPrefixRouteMatches(t *testing.T) { |
| 52 | word := prefixRoute{prefix: "/export", word: true} |
| 53 | if !word.matches("/export") || !word.matches("/export f") { |
| 54 | t.Error("word route should match exact and prefix+space") |
| 55 | } |
| 56 | if word.matches("/exporting") || word.matches("/exportx") { |
| 57 | t.Error("word route must not match a longer token") |
| 58 | } |
| 59 | |
| 60 | raw := prefixRoute{prefix: "/session", word: false} |
| 61 | if !raw.matches("/session") || !raw.matches("/session list") || !raw.matches("/sessionx") { |
| 62 | t.Error("raw route should match by bare prefix") |
| 63 | } |
| 64 | if raw.matches("/sess") { |
| 65 | t.Error("raw route must not match a shorter string") |
| 66 | } |
| 67 | } |