summaryrefslogtreecommitdiffstats
path: root/modules/middleware
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-04 09:13:37 +0800
committerUnknwon <u@gogs.io>2015-08-04 09:13:37 +0800
commite6792796cc25c9a6db91998599a47d3f64016975 (patch)
tree92d56e9cfb13d93bd9e8ea121523221b159c787b /modules/middleware
parent96c1ce960602d65252fbb038e10db629f235936d (diff)
downloadgitea-e6792796cc25c9a6db91998599a47d3f64016975.tar.gz
gitea-e6792796cc25c9a6db91998599a47d3f64016975.zip
minor fix on #1432
Diffstat (limited to 'modules/middleware')
-rw-r--r--modules/middleware/repo.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index e8a362bd4d..0aaecec84b 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -10,20 +10,19 @@ import (
"strings"
"github.com/Unknwon/macaron"
+ "github.com/mcuadros/go-version"
+ "github.com/mssola/user_agent"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/setting"
-
- "github.com/hashicorp/go-version"
- "github.com/mssola/user_agent"
)
const (
FIREFOX_COPY_SUPPORT = "41.0"
- CHROME_COPY_SUPPORT = "43.0.2356"
+ CHROME_COPY_SUPPORT = "43.0.2356"
)
func ApiRepoAssignment() macaron.Handler {
@@ -355,22 +354,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Data["CommitId"] = ctx.Repo.CommitId
userAgent := ctx.Req.Header.Get("User-Agent")
- ua := user_agent.New(userAgent);
+ ua := user_agent.New(userAgent)
browserName, browserVer := ua.Browser()
- sliceVer := strings.Split(browserVer, ".")
- var max int
- if max = len(sliceVer); 3 < max {
- max = 3
- }
- browserVer = strings.Join(sliceVer[:max], ".")
-
- browserVersion, err := version.NewVersion(browserVer)
- chromeConstraint, err := version.NewConstraint(">= " + CHROME_COPY_SUPPORT)
- firefoxConstraint, err := version.NewConstraint(">= " + FIREFOX_COPY_SUPPORT)
-
- ctx.Data["BrowserSupportsCopy"] = (browserName == "Chrome" && chromeConstraint.Check(browserVersion)) || (browserName == "Firefox" && firefoxConstraint.Check(browserVersion))
-
+ ctx.Data["BrowserSupportsCopy"] = (browserName == "Chrome" && version.Compare(browserVer, CHROME_COPY_SUPPORT, ">=")) ||
+ (browserName == "Firefox" && version.Compare(browserVer, FIREFOX_COPY_SUPPORT, ">="))
}
}