summaryrefslogtreecommitdiff
path: root/replacer.go
diff options
context:
space:
mode:
Diffstat (limited to 'replacer.go')
-rw-r--r--replacer.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/replacer.go b/replacer.go
index c82d81d..a38cf55 100644
--- a/replacer.go
+++ b/replacer.go
@@ -116,11 +116,14 @@ func (r *replacer) replace(input, empty string,
continue
}
- // write the substring from the last cursor to this point
- sb.WriteString(input[lastWriteCursor:i])
-
// find the end of the placeholder
end := strings.Index(input[i:], string(phClose)) + i
+ if end < i {
+ continue
+ }
+
+ // write the substring from the last cursor to this point
+ sb.WriteString(input[lastWriteCursor:i])
// trim opening bracket
key := input[i+1 : end]