// Package routing contains various functions related to HTTP routing
package routing

import (
	"errors"
	"path/filepath"
)

// getContentType returns the http header safe content-type attribute for the
// requested path. If the requested path is not formatted correctly with an extension
// then the function will return the zero-value for a string and an error.
// BUG(george-e-shaw-iv) Cannot handle interpreted files such as .php files
// BUG(george-e-shaw-iv) Does not cover the bulk of encountered content types on the web
func GetContentType(path string) (string, error) {
	var contentType string
	fileType := filepath.Ext(path)

	if fileType == "" {
		return contentType, errors.New("Invalid path, contained no period-separated content-type")
	}

	switch fileType {
	case "html":
		contentType = "text/html"
	case "css":
		contentType = "text/css"
	case "js":
		contentType = "text/javascript"
	case "png":
		contentType = "image/png"
	case "jpg":
		fallthrough
	case "jpeg":
		contentType = "image/jpeg"
	default:
		contentType = "text/plain"
	}

	return contentType, nil
}

// Package routing contains various functions related to HTTP routing
package routing

import (
	"errors"
	"strings"
)

// getContentType returns the http header safe content-type attribute for the
// requested path. If the requested path is not formatted correctly with an extension
// then the function will return the zero-value for a string and an error.
// BUG(george-e-shaw-iv) Cannot handle interpreted files such as .php files
// BUG(george-e-shaw-iv) Does not cover the bulk of encountered content types on the web
func GetContentType(path string) (string, error) {
	var contentType string
	splitPath := strings.Split(path, ".")

	if len(splitPath) == 1 && splitPath[0] == path {
		return contentType, errors.New("Invalid path, contained no period-separated content-type")
	}

	fileType := splitPath[len(splitPath)-1]

	switch fileType {
	case "html":
		contentType = "text/html"
	case "css":
		contentType = "text/css"
	case "js":
		contentType = "text/javascript"
	case "png":
		contentType = "image/png"
	case "jpg":
		fallthrough
	case "jpeg":
		contentType = "image/jpeg"
	default:
		contentType = "text/plain"
	}

	return contentType, nil
}

--- 
+++ 
@@ -3,7 +3,7 @@
 
 import (
 	"errors"
-	"strings"
+	"path/filepath"
 )
 
 // getContentType returns the http header safe content-type attribute for the
@@ -13,13 +13,11 @@
 // BUG(george-e-shaw-iv) Does not cover the bulk of encountered content types on the web
 func GetContentType(path string) (string, error) {
 	var contentType string
-	splitPath := strings.Split(path, ".")
+	fileType := filepath.Ext(path)
 
-	if len(splitPath) == 1 && splitPath[0] == path {
+	if fileType == "" {
 		return contentType, errors.New("Invalid path, contained no period-separated content-type")
 	}
-
-	fileType := splitPath[len(splitPath)-1]
 
 	switch fileType {
 	case "html":
Use filepath/Ext in case a user decides to name a file with multiple .
