File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import (
1414// versionPattern matches version strings like @5.2, @5.2.0, etc. and captures major and minor version numbers
1515var versionPattern = regexp .MustCompile (`^@(\d+)\.(\d+)(?:\.(\d+))?$` )
1616
17- // shouldRedirectVersion returns true for versions ≥ 5.3 (format: @major.minor[.patch])
17+ // shouldRedirectVersion returns true for versions ≥ 5.2 (format: @major.minor[.patch])
1818func shouldRedirectVersion (version string ) bool {
1919 matches := versionPattern .FindStringSubmatch (version )
2020 if len (matches ) < 3 {
@@ -27,7 +27,7 @@ func shouldRedirectVersion(version string) bool {
2727 return false
2828 }
2929
30- return major > 5 || (major == 5 && minor >= 3 )
30+ return major > 5 || (major == 5 && minor >= 2 )
3131}
3232
3333// Handler returns an http.Handler that serves the site.
@@ -146,7 +146,7 @@ func (s *Site) Handler() http.Handler {
146146 contentVersion = r .URL .Path [1 : 1 + end ]
147147 }
148148
149- // Redirect versions ≥ 5.3 to new docs domain with path preservation
149+ // Redirect versions ≥ 5.2 to new docs domain with path preservation
150150 version := "@" + contentVersion
151151 if shouldRedirectVersion (version ) {
152152 newURL := "https://www.sourcegraph.com/docs/" + contentVersion + "/"
Original file line number Diff line number Diff line change @@ -272,11 +272,14 @@ func TestSite_Handler(t *testing.T) {
272272 checkResponseStatus (t , rr , http .StatusNotFound )
273273 })
274274
275- t .Run ("version 5.2 - no redirect" , func (t * testing.T ) {
275+ t .Run ("version 5.2 - should redirect" , func (t * testing.T ) {
276276 rr := httptest .NewRecorder ()
277277 req , _ := http .NewRequest ("GET" , "/@5.2" , nil )
278278 handler .ServeHTTP (rr , req )
279- checkResponseStatus (t , rr , http .StatusNotFound )
279+ checkResponseStatus (t , rr , http .StatusPermanentRedirect )
280+ if got , want := rr .Header ().Get ("Location" ), "https://www.sourcegraph.com/docs/5.2/" ; got != want {
281+ t .Errorf ("got redirect Location %q, want %q" , got , want )
282+ }
280283 })
281284
282285 t .Run ("version 5.3 - should redirect" , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments