File size: 739 Bytes
103a866
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4540c3b
103a866
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script>
    function onDOMContentLoaded() {
        document.removeEventListener("DOMContentLoaded", onDOMContentLoaded);
        
        var currentUrl = window.location.href;

        var regex = /https:\/\/([\w]+)-([\w-]+)\.static\.hf\.space/;
        var match = currentUrl.match(regex);

        if (match) {
            var repo = match[1];
            var space = match[2];
            var targetUrl = "https://huggingface.co/spaces/" + repo + "/" + space;
            console.log("Redirecting to:", targetUrl);
            window.location.href = targetUrl;
        } else {
            console.error("URL pattern does not match.");
        }
    }
    document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
</script>