github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/util/baseurl.ts (about) 1 // There's a copy of this function in welcome.html 2 // TODO: maybe dedup somehow? 3 function basename() { 4 const baseURLMetaTag = document.querySelector( 5 'meta[name="pyroscope-base-url"]' 6 ) as HTMLMetaElement; 7 8 if (!baseURLMetaTag) { 9 return undefined; 10 } 11 12 const baseURL = baseURLMetaTag.content; 13 14 if (!baseURL) { 15 return undefined; 16 } 17 const url = new URL(baseURL, window.location.href); 18 return url.pathname; 19 } 20 21 export default basename;