|
@@ -155,7 +155,7 @@ func (spec Spec) ApplyString(seed *prng.Seed, input string) (string, error) {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return "", errors.Trace(err)
|
|
return "", errors.Trace(err)
|
|
|
}
|
|
}
|
|
|
- value = re.ReplaceAllString(value, replacement)
|
|
|
|
|
|
|
+ value = re.ReplaceAllString(value, string(replacement))
|
|
|
}
|
|
}
|
|
|
return value, nil
|
|
return value, nil
|
|
|
}
|
|
}
|
|
@@ -173,7 +173,7 @@ func (spec Spec) Apply(seed *prng.Seed, input []byte) ([]byte, error) {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, errors.Trace(err)
|
|
return nil, errors.Trace(err)
|
|
|
}
|
|
}
|
|
|
- value = re.ReplaceAll(value, []byte(replacement))
|
|
|
|
|
|
|
+ value = re.ReplaceAll(value, replacement)
|
|
|
}
|
|
}
|
|
|
return value, nil
|
|
return value, nil
|
|
|
}
|
|
}
|
|
@@ -181,7 +181,7 @@ func (spec Spec) Apply(seed *prng.Seed, input []byte) ([]byte, error) {
|
|
|
// makeRegexAndRepl generates the regex and replacement for a given seed and
|
|
// makeRegexAndRepl generates the regex and replacement for a given seed and
|
|
|
// transform. The same seed can be supplied to produce the same output, for
|
|
// transform. The same seed can be supplied to produce the same output, for
|
|
|
// replay.
|
|
// replay.
|
|
|
-func makeRegexAndRepl(seed *prng.Seed, transform [2]string) (*regexp.Regexp, string, error) {
|
|
|
|
|
|
|
+func makeRegexAndRepl(seed *prng.Seed, transform [2]string) (*regexp.Regexp, []byte, error) {
|
|
|
|
|
|
|
|
// TODO: the compiled regexp and regen could be cached, but the seed is an
|
|
// TODO: the compiled regexp and regen could be cached, but the seed is an
|
|
|
// issue with caching the regen.
|
|
// issue with caching the regen.
|
|
@@ -192,18 +192,18 @@ func makeRegexAndRepl(seed *prng.Seed, transform [2]string) (*regexp.Regexp, str
|
|
|
}
|
|
}
|
|
|
rg, err := regen.NewGenerator(transform[1], args)
|
|
rg, err := regen.NewGenerator(transform[1], args)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return nil, "", errors.Trace(err)
|
|
|
|
|
|
|
+ return nil, nil, errors.Trace(err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
replacement, err := rg.Generate()
|
|
replacement, err := rg.Generate()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return nil, "", errors.Trace(err)
|
|
|
|
|
|
|
+ return nil, nil, errors.Trace(err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
re, err := regexp.Compile(transform[0])
|
|
re, err := regexp.Compile(transform[0])
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return nil, "", errors.Trace(err)
|
|
|
|
|
|
|
+ return nil, nil, errors.Trace(err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return re, string(replacement), nil
|
|
|
|
|
|
|
+ return re, replacement, nil
|
|
|
}
|
|
}
|