(flagName: string)
| 260 | // If the input is a string like test-cloud.trigger.dev, we should automatically add https:// |
| 261 | // If the input is a string like localhost:3030, we should automatically add http:// |
| 262 | function createUrlValidator(flagName: string): (input: string) => string { |
| 263 | return (input: string) => { |
| 264 | try { |
| 265 | const possibleUrl = tryToCreateValidUrlFromValue(input); |
| 266 | |
| 267 | new URL(possibleUrl); |
| 268 | |
| 269 | return possibleUrl; |
| 270 | } catch (e) { |
| 271 | throw new Error(`Please enter a valid URL for the ${flagName} flag`); |
| 272 | } |
| 273 | }; |
| 274 | } |
| 275 | |
| 276 | function tryToCreateValidUrlFromValue(input: string): string { |
| 277 | let possibleUrl = input; |
no test coverage detected
searching dependent graphs…