MCPcopy Create free account
hub / github.com/github/awesome-copilot / validateHttpsUrl

Function validateHttpsUrl

eng/external-plugin-validation.mjs:136–157  ·  view source on GitHub ↗
(value, fieldName, prefix, errors, options = {})

Source from the content-addressed store, hash-verified

134}
135
136function 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
159function validateAuthor(author, prefix, errors, required) {
160 if (author === undefined) {

Callers 3

validateAuthorFunction · 0.85
validateRepositoryFunction · 0.85
validateHomepageFunction · 0.85

Calls 1

isNonEmptyStringFunction · 0.85

Tested by

no test coverage detected