# Class 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 src/router/common/glob.js:49

##### Index

### Constructors

constructor

### Properties

glob
regexp
text

### Methods

matches
fromString

## Constructors

### constructor

- new Glob(text: string): Glob

  #### Parameters

  - text: string

  #### Returns Glob

  - Defined in src/router/common/glob.js:61

## Properties

### glob

glob: string[]

- Defined in src/router/common/glob.js:70

### regexp

regexp: RegExp

- Defined in src/router/common/glob.js:84

### text

text: string

- Defined in src/router/common/glob.js:65

## Methods

### matches

- matches(name: any): boolean

  #### Parameters

  - name: any

  #### Returns boolean

  - Defined in src/router/common/glob.js:86

### `Static` fromString

- fromString(text: string): Glob

  Returns a glob from the string, or null if the string isn't Glob-like

  #### Parameters

  - text: string

  #### Returns Glob

  - Defined in src/router/common/glob.js:54