MCPcopy Create free account
hub / github.com/pollinations/pollinations / validateRedirectUriFormat

Function validateRedirectUriFormat

shared/auth/api-key-creation.ts:67–92  ·  view source on GitHub ↗
(redirectUri: string)

Source from the content-addressed store, hash-verified

65};
66
67export function validateRedirectUriFormat(redirectUri: string): void {
68 if (!/^[a-z][a-z0-9+\-.]*:\/\/.+/.test(redirectUri)) {
69 throw new HTTPException(400, {
70 message: "Must be a valid URL with a scheme (e.g. https://...)",
71 });
72 }
73 let parsed: URL;
74 try {
75 parsed = new URL(redirectUri);
76 } catch {
77 throw new HTTPException(400, {
78 message: "Must be a valid URL with a scheme (e.g. https://...)",
79 });
80 }
81 if (parsed.hash) {
82 throw new HTTPException(400, {
83 message: "Redirect URI must not include a fragment",
84 });
85 }
86 if (!isAllowedRedirectUrl(parsed)) {
87 throw new HTTPException(400, {
88 message:
89 "Redirect URI must use https://, except http:// is allowed for loopback hosts",
90 });
91 }
92}
93
94function parseMetadata(
95 raw: string | null | undefined,

Callers 2

api-keys.tsFile · 0.90
createApiKeyForUserFunction · 0.85

Calls 1

isAllowedRedirectUrlFunction · 0.90

Tested by

no test coverage detected