mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	caddyfile: prevent adding trailing space on line before env variable (#7215)
This commit is contained in:
		
							parent
							
								
									e0a8f9541d
								
							
						
					
					
						commit
						6d73d85c1f
					
				| @ -224,7 +224,7 @@ func Format(input []byte) []byte { | ||||
| 			openBrace = false | ||||
| 			if beginningOfLine { | ||||
| 				indent() | ||||
| 			} else if !openBraceSpace { | ||||
| 			} else if !openBraceSpace || !unicode.IsSpace(last) { | ||||
| 				write(' ') | ||||
| 			} | ||||
| 			write('{') | ||||
| @ -241,7 +241,7 @@ func Format(input []byte) []byte { | ||||
| 		case ch == '{': | ||||
| 			openBrace = true | ||||
| 			openBraceSpace = spacePrior && !beginningOfLine | ||||
| 			if openBraceSpace { | ||||
| 			if openBraceSpace && newLines == 0 { | ||||
| 				write(' ') | ||||
| 			} | ||||
| 			openBraceWritten = false | ||||
|  | ||||
| @ -444,6 +444,21 @@ block2 { | ||||
| 			input:       "block {respond \"All braces should remain: {{now | date `2006`}}\"}", | ||||
| 			expect:      "block {respond \"All braces should remain: {{now | date `2006`}}\"}", | ||||
| 		}, | ||||
| 		{ | ||||
| 			description: "No trailing space on line before env variable", | ||||
| 			input: `{ | ||||
| 	a | ||||
| 
 | ||||
| 	{$ENV_VAR} | ||||
| } | ||||
| `, | ||||
| 			expect: `{ | ||||
| 	a | ||||
| 
 | ||||
| 	{$ENV_VAR} | ||||
| } | ||||
| `, | ||||
| 		}, | ||||
| 	} { | ||||
| 		// the formatter should output a trailing newline, | ||||
| 		// even if the tests aren't written to expect that | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user