<commit_before>package controllers

import (
	"github.com/robfig/revel"
	"os"
	fpath "path/filepath"
)

type Static struct {
	*revel.Controller
}

func (c Static) ServeDir(prefix, filepath string) revel.Result {
	var basePath string

	if !fpath.IsAbs(prefix) {
		basePath = revel.BasePath
	}

	fname := fpath.Join(basePath, fpath.FromSlash(prefix), fpath.FromSlash(filepath))
	file, err := os.Open(fname)
	if os.IsNotExist(err) {
		revel.WARN.Printf("File not found (%s): %s ", fname, err)
		return c.NotFound("")
	} else if err != nil {
		revel.WARN.Printf("Problem opening file (%s): %s ", fname, err)
		return c.NotFound("This was found but not sure why we couldn't open it.")
	}
	return c.RenderFile(file, "")
}

func (c Static) ServeFile(filepath string) revel.Result {
	return c.ServeDir("", filepath)
}<commit_msg>Fix absolute path routing for ServeFile()<commit_after>package controllers

import (
	"github.com/robfig/revel"
	"os"
	fpath "path/filepath"
)

type Static struct {
	*revel.Controller
}

func (c Static) ServeDir(prefix, filepath string) revel.Result {
	var basePath string

	if !fpath.IsAbs(prefix) {
		basePath = revel.BasePath
	}

	fname := fpath.Join(basePath, fpath.FromSlash(prefix), fpath.FromSlash(filepath))
	file, err := os.Open(fname)
	if os.IsNotExist(err) {
		revel.WARN.Printf("File not found (%s): %s ", fname, err)
		return c.NotFound("")
	} else if err != nil {
		revel.WARN.Printf("Problem opening file (%s): %s ", fname, err)
		return c.NotFound("This was found but not sure why we couldn't open it.")
	}
	return c.RenderFile(file, "")
}

func (c Static) ServeFile(filepath string) revel.Result {
	if !fpath.IsAbs(filepath) {
		return c.ServeDir("", filepath)
	}
	return c.ServeDir("/", filepath)
}
{'fraction_non_alphanumeric': 0.14680483592400692, 'fraction_numerical': 0.0, 'mean_word_length': 4.43125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3819275', 'n_tokens_mistral': 671, 'n_tokens_neox': 640, 'n_words': 164}