kopia lustrzana https://codeberg.org/Codeberg/pages-server
				
				
				
			Fix redirects for pages repo
							rodzic
							
								
									203e230905
								
							
						
					
					
						commit
						2e0608c270
					
				| 
						 | 
				
			
			@ -148,6 +148,12 @@ func handler(ctx *fasthttp.RequestCtx) {
 | 
			
		|||
		// Check if the first directory is a repo with the second directory as a branch
 | 
			
		||||
		// example.codeberg.page/myrepo/@main/index.html
 | 
			
		||||
		if len(pathElements) > 1 && strings.HasPrefix(pathElements[1], "@") {
 | 
			
		||||
			if targetRepo == "pages" {
 | 
			
		||||
				// example.codeberg.org/pages/@... redirects to example.codeberg.org/@...
 | 
			
		||||
				ctx.Redirect("/" + strings.Join(pathElements[1:], "/"), fasthttp.StatusMovedPermanently)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if tryBranch(pathElements[0], pathElements[1][1:], pathElements[2:],
 | 
			
		||||
				"/"+pathElements[0]+"/%p",
 | 
			
		||||
			) {
 | 
			
		||||
| 
						 | 
				
			
			@ -171,7 +177,8 @@ func handler(ctx *fasthttp.RequestCtx) {
 | 
			
		|||
 | 
			
		||||
		// Check if the first directory is a repo with a "pages" branch
 | 
			
		||||
		// example.codeberg.page/myrepo/index.html
 | 
			
		||||
		if tryBranch(pathElements[0], "pages", pathElements[1:], "") {
 | 
			
		||||
		// example.codeberg.page/pages/... is not allowed here.
 | 
			
		||||
		if pathElements[0] != "pages" && tryBranch(pathElements[0], "pages", pathElements[1:], "") {
 | 
			
		||||
			tryUpstream()
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								main.go
								
								
								
								
							
							
						
						
									
										4
									
								
								main.go
								
								
								
								
							| 
						 | 
				
			
			@ -2,11 +2,13 @@
 | 
			
		|||
//
 | 
			
		||||
// Mapping custom domains is not static anymore, but can be done with DNS:
 | 
			
		||||
//
 | 
			
		||||
// 1) add a "domains.txt" text file to your repository, containing the allowed domains, separated by new lines.
 | 
			
		||||
// 1) add a "domains.txt" text file to your repository, containing the allowed domains, separated by new lines. The
 | 
			
		||||
// first line will be the canonical domain/URL; all other occurrences will be redirected to it.
 | 
			
		||||
//
 | 
			
		||||
// 2) add a CNAME entry to your domain, pointing to "[[{branch}.]{repo}.]{owner}.codeberg.page" (repo defaults to
 | 
			
		||||
// "pages", "branch" defaults to the default branch if "repo" is "pages", or to "pages" if "repo" is something else):
 | 
			
		||||
//      www.example.org. IN CNAME main.pages.example.codeberg.page.
 | 
			
		||||
//
 | 
			
		||||
// 3) if a CNAME is set for "www.example.org", you can redirect there from the naked domain by adding an ALIAS record
 | 
			
		||||
// for "example.org" (if your provider allows ALIAS or similar records):
 | 
			
		||||
//      example.org IN ALIAS codeberg.page.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue