Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix newline handling at the end of fragments #623

Merged
merged 1 commit into from
Jan 6, 2020

Conversation

LadyNamedLaura
Copy link
Contributor

$ matches both end of string and end of line.
so /\n$/ matches \n\n anywhere in the string.
while /\n\Z/ only matches \n at the end of the string.

irb(main):021:0> "a\n\nb" =~ /\n$/
=> 1
irb(main):022:0> "a\n\nb" =~ /\n\Z/
=> nil
irb(main):023:0> "a\n\nb\n" =~ /\n$/
=> 1
irb(main):024:0> "a\n\nb\n" =~ /\n\Z/
=> 4

`$` matches both end of string and end of line.
so `/\n$/` matches `\n\n` anywhere in the string.
while `/\n\Z/` only matches `\n` at the end of the string.

```
irb(main):021:0> "a\n\nb" =~ /\n$/
=> 1
irb(main):022:0> "a\n\nb" =~ /\n\Z/
=> nil
irb(main):023:0> "a\n\nb\n" =~ /\n$/
=> 1
irb(main):024:0> "a\n\nb\n" =~ /\n\Z/
=> 4
```
@LadyNamedLaura LadyNamedLaura requested a review from a team as a code owner January 3, 2020 15:21
@LadyNamedLaura
Copy link
Contributor Author

the one failed travis job failed on bundle exec rake 'litmus:install_agent[puppet6]' which I don't think this code is involved in.

Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I've rekicked the centos6 tests. the repo is sometimes a bit temperamental.

@DavidS DavidS changed the title Search for newlines at end of string, not at end of line Fix newline handling at the end of fragments Jan 6, 2020
@DavidS DavidS added the bugfix label Jan 6, 2020
@DavidS DavidS merged commit 4db881b into puppetlabs:master Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants