MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / isPictureWithProtocol

Function isPictureWithProtocol

api/src/routes/protected/settings.ts:46–54  ·  view source on GitHub ↗
(picture?: string)

Source from the content-addressed store, hash-verified

44 * @returns Whether the url is a picture with a valid protocol.
45 */
46export const isPictureWithProtocol = (picture?: string): boolean => {
47 if (!picture) return false;
48 try {
49 const url = new URL(picture);
50 return url.protocol == 'http:' || url.protocol == 'https:';
51 } catch {
52 return false;
53 }
54};
55
56const commonImageExtensions = [
57 'apng',

Callers 2

settings.test.tsFile · 0.85
isValidPictureUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected