(tag: string)
| 35 | } |
| 36 | |
| 37 | export const splitTag = (tag: string): Tag => { |
| 38 | // Parse tag for version e.g roboto@1.1.1 |
| 39 | const [id, version] = tag.split('@'); |
| 40 | if (!id) { |
| 41 | throw new StatusError( |
| 42 | 400, |
| 43 | 'Bad Request. Unable to parse font ID from tag.', |
| 44 | ); |
| 45 | } |
| 46 | if (!version) { |
| 47 | throw new StatusError( |
| 48 | 400, |
| 49 | 'Bad Request. Unable to parse version from tag.', |
| 50 | ); |
| 51 | } |
| 52 | if (version.split('.').length !== 3) { |
| 53 | throw new StatusError(400, 'Bad Request. Invalid semver version.'); |
| 54 | } |
| 55 | |
| 56 | return { id, version }; |
| 57 | }; |
no outgoing calls
no test coverage detected