( permissionRule: string, )
| 157 | * Parse a permission rule string into a structured rule object. |
| 158 | */ |
| 159 | export function parsePermissionRule( |
| 160 | permissionRule: string, |
| 161 | ): ShellPermissionRule { |
| 162 | // Check for legacy :* prefix syntax first (backwards compatibility) |
| 163 | const prefix = permissionRuleExtractPrefix(permissionRule) |
| 164 | if (prefix !== null) { |
| 165 | return { |
| 166 | type: 'prefix', |
| 167 | prefix, |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // Check for new wildcard syntax (contains * but not :* at end) |
| 172 | if (hasWildcards(permissionRule)) { |
| 173 | return { |
| 174 | type: 'wildcard', |
| 175 | pattern: permissionRule, |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Otherwise, it's an exact match |
| 180 | return { |
| 181 | type: 'exact', |
| 182 | command: permissionRule, |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Generate permission update suggestion for an exact command match. |
no test coverage detected