MCPcopy
hub / github.com/midudev/libros-programacion-gratis / normalizeUrl

Function normalizeUrl

web/src/lib/contribution.ts:32–45  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

30 .trim();
31
32export const normalizeUrl = (value: string) => {
33 try {
34 const url = new URL(value.trim());
35
36 if (url.protocol !== 'http:' && url.protocol !== 'https:') {
37 return '';
38 }
39
40 url.hash = '';
41 return url.toString().replace(/\/$/, '');
42 } catch {
43 return '';
44 }
45};
46
47export const isSupportedUrl = (value: string) => normalizeUrl(value) !== '';
48

Callers 3

isSupportedUrlFunction · 0.85
createSearchableCatalogFunction · 0.85
findPotentialDuplicatesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected