# Module router/common/glob

Matches state names using glob-like pattern strings.

Globs can be used in specific APIs including:

- [[StateService.is]]
- [[StateService.includes]]
- The first argument to Hook Registration functions like [[TransitionService.onStart]]
  - [[HookMatchCriteria]] and [[HookMatchCriterion]]

A `Glob` string is a pattern which matches state names. Nested state names are split into segments (separated by a dot) when processing. The state named `foo.bar.baz` is split into three segments ['foo', 'bar', 'baz']

Globs work according to the following rules:

### Exact match:

The glob `'A.B'` matches the state named exactly `'A.B'`.

Glob | Matches states named | Does not match state named
--- | --- | ---
`'A'` | `'A'` | `'B'` , `'A.C'`
`'A.B'` | `'A.B'` | `'A'` , `'A.B.C'`
`'foo'` | `'foo'` | `'FOO'` , `'foo.bar'`

### Single star (`*`)

A single star (`*`) is a wildcard that matches exactly one segment.

Glob | Matches states named | Does not match state named
--- | --- | ---
`'*'` | `'A'` , `'Z'` | `'A.B'` , `'Z.Y.X'`
`'A.*'` | `'A.B'` , `'A.C'` | `'A'` , `'A.B.C'`
`'A.*.*'` | `'A.B.C'` , `'A.X.Y'` | `'A'`, `'A.B'` , `'Z.Y.X'`

### Double star (`**`)

A double star (`'**'`) is a wildcard that matches zero or more segments

Glob | Matches states named | Does not match state named
--- | --- | ---
`'**'` | `'A'` , `'A.B'`, `'Z.Y.X'` | (matches all states)
`'A.**'` | `'A'` , `'A.B'` , `'A.C.X'` | `'Z.Y.X'`
`'**.X'` | `'X'` , `'A.X'` , `'Z.Y.X'` | `'A'` , `'A.login.Z'`
`'A.**.X'` | `'A.X'` , `'A.B.X'` , `'A.B.C.X'` | `'A'` , `'A.B.C'`

- Defined in router/common/glob.js:1

### Index

### Classes

Glob