(value, fieldName, prefix, errors, options = {})
| 134 | } |
| 135 | |
| 136 | function validateHttpsUrl(value, fieldName, prefix, errors, options = {}) { |
| 137 | if (!isNonEmptyString(value)) { |
| 138 | errors.push(`${prefix}: "${fieldName}" must be a non-empty string`); |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | let parsed; |
| 143 | try { |
| 144 | parsed = new URL(value); |
| 145 | } catch { |
| 146 | errors.push(`${prefix}: "${fieldName}" must be a valid URL`); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | if (parsed.protocol !== "https:") { |
| 151 | errors.push(`${prefix}: "${fieldName}" must use https`); |
| 152 | } |
| 153 | |
| 154 | if (options.githubOnly && parsed.hostname !== "github.com") { |
| 155 | errors.push(`${prefix}: "${fieldName}" must point to https://github.com/...`); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | function validateAuthor(author, prefix, errors, required) { |
| 160 | if (author === undefined) { |
no test coverage detected