mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Fix duplicate sub-path for avatars (#31365)
Fix #31361, and add tests And this PR introduces an undocumented & debug-purpose-only config option: `USE_SUB_URL_PATH`. It does nothing for end users, it only helps the development of sub-path related problems. And also fix #31366 Co-authored-by: @ExplodingDragon
This commit is contained in:
		| @@ -46,14 +46,14 @@ func TestMakeAbsoluteURL(t *testing.T) { | ||||
|  | ||||
| 	ctx := context.Background() | ||||
| 	assert.Equal(t, "http://cfg-host/sub/", MakeAbsoluteURL(ctx, "")) | ||||
| 	assert.Equal(t, "http://cfg-host/sub/foo", MakeAbsoluteURL(ctx, "foo")) | ||||
| 	assert.Equal(t, "http://cfg-host/sub/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
| 	assert.Equal(t, "http://cfg-host/foo", MakeAbsoluteURL(ctx, "foo")) | ||||
| 	assert.Equal(t, "http://cfg-host/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
| 	assert.Equal(t, "http://other/foo", MakeAbsoluteURL(ctx, "http://other/foo")) | ||||
|  | ||||
| 	ctx = context.WithValue(ctx, RequestContextKey, &http.Request{ | ||||
| 		Host: "user-host", | ||||
| 	}) | ||||
| 	assert.Equal(t, "http://cfg-host/sub/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
| 	assert.Equal(t, "http://cfg-host/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
|  | ||||
| 	ctx = context.WithValue(ctx, RequestContextKey, &http.Request{ | ||||
| 		Host: "user-host", | ||||
| @@ -61,7 +61,7 @@ func TestMakeAbsoluteURL(t *testing.T) { | ||||
| 			"X-Forwarded-Host": {"forwarded-host"}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	assert.Equal(t, "http://cfg-host/sub/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
| 	assert.Equal(t, "http://cfg-host/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
|  | ||||
| 	ctx = context.WithValue(ctx, RequestContextKey, &http.Request{ | ||||
| 		Host: "user-host", | ||||
| @@ -70,7 +70,7 @@ func TestMakeAbsoluteURL(t *testing.T) { | ||||
| 			"X-Forwarded-Proto": {"https"}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	assert.Equal(t, "https://forwarded-host/sub/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
| 	assert.Equal(t, "https://forwarded-host/foo", MakeAbsoluteURL(ctx, "/foo")) | ||||
| } | ||||
|  | ||||
| func TestIsCurrentGiteaSiteURL(t *testing.T) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user