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

(assert-internal): stringLike function does not support multiline strings #17691

Closed
diegotry opened this issue Nov 24, 2021 · 1 comment · Fixed by #17692
Closed

(assert-internal): stringLike function does not support multiline strings #17691

diegotry opened this issue Nov 24, 2021 · 1 comment · Fixed by #17692
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@diegotry
Copy link
Contributor

diegotry commented Nov 24, 2021

What is the problem?

I am writing an unit test using the stringLike() as suggested by @nija-at @ #16827

The value being checked contains line breaks (\n) which fails on current implementation of stringLike()

Reproduction Steps

Copied the code from the aws-cdk:

function escapeRegex(s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');}
let regex = `^${"*includeHeaders*".split('*').map(escapeRegex).join('.*')}$`

// value above is "^.*includeHeaders.*$"

let regexp = new RegExp(regex);
let value = "something includeHeaders\nsomething"
let regexMatch = regexp.test(value);
console.log(regexp.test(value));

output is "false"

What did you expect to happen?

to return true

What actually happened?

it returned false

CDK CLI Version

1.134.0

Framework Version

No response

Node.js Version

12

OS

mac

Language

Typescript

Language Version

No response

Other information

Issue can be fixed by:

- let regexp = new RegExp(regex);
+ let regexp = new RegExp(regex, 'm');

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline

I am going to submit a PR soon.

@diegotry diegotry added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2021
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Nov 24, 2021
@diegotry diegotry changed the title (cdk-assert): stringLike function does not support multiline strings (assert-internal): stringLike function does not support multiline strings Nov 24, 2021
@peterwoodworth peterwoodworth added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2021
@mergify mergify bot closed this as completed in #17692 Nov 25, 2021
mergify bot pushed a commit that referenced this issue Nov 25, 2021
Updates the `RegExp` constructor to support multiline. Resolves #17691

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

beezly pushed a commit to beezly/aws-cdk that referenced this issue Nov 29, 2021
Updates the `RegExp` constructor to support multiline. Resolves aws#17691

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Updates the `RegExp` constructor to support multiline. Resolves aws#17691

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants