<commit_before>package ui

import (
	"io"
	"net/http"

	"os"

	"github.com/rancher/norman/parse"
	"github.com/rancher/rancher/pkg/settings"
	"github.com/sirupsen/logrus"
)

var uiURL = "https://releases.rancher.com/ui/latest2/index.html"

func Content() http.Handler {
	return http.FileServer(http.Dir("ui"))
}

func UI(next http.Handler) http.Handler {
	local := false
	_, err := os.Stat("ui/index.html")
	if err == nil {
		local = true
	}

	if local && settings.ServerVersion.Get() == "master" {
		local = false
	}

	return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
		if parse.IsBrowser(req, true) {
			if local {
				http.ServeFile(resp, req, "ui/index.html")
			} else {
				ui(resp, req)
			}
		} else {
			next.ServeHTTP(resp, req)
		}
	})
}

func ui(resp http.ResponseWriter, req *http.Request) {<commit_msg>Assume versions that don't start with v use latest UI<commit_after>package ui

import (
	"io"
	"net/http"
	"os"
	"strings"

	"github.com/rancher/norman/parse"
	"github.com/rancher/rancher/pkg/settings"
	"github.com/sirupsen/logrus"
)

var uiURL = "https://releases.rancher.com/ui/latest2/index.html"

func Content() http.Handler {
	return http.FileServer(http.Dir("ui"))
}

func UI(next http.Handler) http.Handler {
	local := false
	_, err := os.Stat("ui/index.html")
	if err == nil {
		local = true
	}

	if local && !strings.HasPrefix(settings.ServerVersion.Get(), "v") {
		local = false
	}

	return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
		if parse.IsBrowser(req, true) {
			if local {
				http.ServeFile(resp, req, "ui/index.html")
			} else {
				ui(resp, req)
			}
		} else {
			next.ServeHTTP(resp, req)
		}
	})
}

func ui(resp http.ResponseWriter, req *http.Request) {
{'fraction_non_alphanumeric': 0.16027475672581568, 'fraction_numerical': 0.0011448196908986834, 'mean_word_length': 3.612137203166227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1823734', 'n_tokens_mistral': 726, 'n_tokens_neox': 674, 'n_words': 130}