(ref: string)
| 191 | } |
| 192 | |
| 193 | export function parseShellRunResourceRef(ref: string): { shellRunId: string } | null { |
| 194 | let url: URL; |
| 195 | try { |
| 196 | url = new URL(ref); |
| 197 | } catch { |
| 198 | return null; |
| 199 | } |
| 200 | if ( |
| 201 | url.protocol !== 'maka:' || |
| 202 | url.hostname !== 'runtime' || |
| 203 | url.username || |
| 204 | url.password || |
| 205 | url.port || |
| 206 | url.search || |
| 207 | url.hash |
| 208 | ) |
| 209 | return null; |
| 210 | const match = SHELL_RUN_RESOURCE_PATH_PATTERN.exec(url.pathname); |
| 211 | if (!match) return null; |
| 212 | const encodedId = match[1]; |
| 213 | if (!encodedId) return null; |
| 214 | try { |
| 215 | const shellRunId = decodeURIComponent(encodedId); |
| 216 | if (!isShellRunId(shellRunId) || ref !== shellRunResourceRef(shellRunId)) return null; |
| 217 | return { shellRunId }; |
| 218 | } catch { |
| 219 | return null; |
| 220 | } |
| 221 | } |
no test coverage detected