loading up the forgejo repo on tangled to test page performance
fork

Configure Feed

Select the types of activity you want to include in your feed.

at forgejo 22 lines 853 B view raw
1// Convert an absolute or relative URL to an absolute URL with the current origin. It only 2// processes absolute HTTP/HTTPS URLs or relative URLs like '/xxx' or '//host/xxx'. 3// NOTE: Keep this function in sync with clone_script.tmpl 4export function toOriginUrl(urlStr) { 5 try { 6 if (urlStr.startsWith('http://') || urlStr.startsWith('https://') || urlStr.startsWith('/')) { 7 const {origin, protocol, hostname, port} = window.location; 8 const url = new URL(urlStr, origin); 9 url.protocol = protocol; 10 url.hostname = hostname; 11 url.port = port || (protocol === 'https:' ? '443' : '80'); 12 return url.toString(); 13 } 14 } catch {} 15 return urlStr; 16} 17 18window.customElements.define('origin-url', class extends HTMLElement { 19 connectedCallback() { 20 this.textContent = toOriginUrl(this.getAttribute('data-url')); 21 } 22});