handy online tools for AT Protocol boat.kelinci.net
atproto bluesky atcute typescript solidjs
at trunk 18 lines 455 B view raw
1import * as v from '@badrap/valita'; 2 3export const serviceUrlString = v.string().assert((input) => { 4 const url = URL.parse(input); 5 6 return ( 7 url !== null && 8 (url.protocol === 'https:' || url.protocol === 'http:') && 9 url.pathname === '/' && 10 url.search === '' && 11 url.hash === '' 12 ); 13}, `must be a valid atproto service url`); 14 15export const isServiceUrlString = (str: string) => { 16 const result = serviceUrlString.try(str); 17 return result.ok; 18};