MCPcopy
hub / github.com/dubinc/dub / getUrlFromString

Function getUrlFromString

packages/utils/src/functions/urls.ts:26–34  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

24}
25
26export const getUrlFromString = (str: string) => {
27 if (isValidUrl(str)) return str;
28 try {
29 if (str.includes(".") && !str.includes(" ")) {
30 return new URL(`https://${str}`).toString();
31 }
32 } catch (_) {}
33 return str;
34};
35
36export const getUrlObjFromString = (str: string) => {
37 if (isValidUrl(str)) return new URL(str);

Callers 9

LinkPreviewFunction · 0.90
CreateLinkMiddlewareFunction · 0.90
processLinkFunction · 0.90
utils.tsFile · 0.90
parseUrlSchemaAllowEmptyFunction · 0.90
LinkFormatFunction · 0.90
ModalProviderClientFunction · 0.90

Calls 1

isValidUrlFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…