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

test: fix RegExp nits #13770

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/inspector/test-inspector-ip-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function checkListResponse(instance, err, response) {
const match = wsUrl.match(/^ws:\/\/(.*):9229\/(.*)/);
assert.strictEqual(ip, match[1]);
assert.strictEqual(res['id'], match[2]);
assert.strictEqual(ip, res['devtoolsFrontendUrl'].match(/.*ws=(.*):9229/)[1]);
assert.strictEqual(ip, res['devtoolsFrontendUrl'].match(/ws=(.*):9229/)[1]);
Copy link
Contributor

@not-an-aardvark not-an-aardvark Jun 19, 2017

Choose a reason for hiding this comment

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

This change actually can have an effect on the match returned:

const string = 'ws=0.0.0.0:9229 ws=1.1.1.1:9229';

string.match(/.*ws=(.*):9229/)[1] // => '1.1.1.1'

string.match(/ws=(.*):9229/)[1] // => '0.0.0.0:9229 ws=1.1.1.1'

I'm not sure whether this matters for this particular test case.

[EDITED by @Trott to correct small typo in code: 9299 -> 9229]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry, I've missed this part can take up similar parts.

However, this RegExp checks a URL like:
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=192.168.137.2:9229/151fc61d-6045-4692-b651-58bb5ba2c83d

If there is any chance this URL can have two ws= parts, let me know and I will remove this commit.

cc @nodejs/v8-inspector

Copy link
Member

Choose a reason for hiding this comment

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

I would leave it as is. If there's no good reason to make the test more lax, don't make it more lax. :-D

If the intention is to introduce a lint rule that would flag something like this line, it can always be disabled on just this line with a comment.

instance.childInstanceDone = true;
}

Expand Down