File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
frontend/dockerfile/parser Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,6 @@ type Heredoc struct {
114
114
var (
115
115
dispatch map [string ]func (string , * directives ) (* Node , map [string ]bool , error )
116
116
reWhitespace = regexp .MustCompile (`[\t\v\f\r ]+` )
117
- reComment = regexp .MustCompile (`^#.*$` )
118
117
reHeredoc = regexp .MustCompile (`^(\d*)<<(-?)([^<]*)$` )
119
118
reLeadingTabs = regexp .MustCompile (`(?m)^\t+` )
120
119
)
@@ -487,7 +486,10 @@ func ChompHeredocContent(src string) string {
487
486
}
488
487
489
488
func trimComments (src []byte ) []byte {
490
- return reComment .ReplaceAll (src , []byte {})
489
+ if ! isComment (src ) {
490
+ return src
491
+ }
492
+ return nil
491
493
}
492
494
493
495
func trimLeadingWhitespace (src []byte ) []byte {
@@ -501,7 +503,8 @@ func trimNewline(src []byte) []byte {
501
503
}
502
504
503
505
func isComment (line []byte ) bool {
504
- return reComment .Match (trimLeadingWhitespace (trimNewline (line )))
506
+ line = trimLeadingWhitespace (line )
507
+ return len (line ) > 0 && line [0 ] == '#'
505
508
}
506
509
507
510
func isEmptyContinuationLine (line []byte ) bool {
You can’t perform that action at this time.
0 commit comments