Fix crash of extension when proxy settings address has wrong format#1046
Merged
datho7561 merged 1 commit intoredhat-developer:mainfrom Dec 12, 2024
Merged
Conversation
datho7561
requested changes
Dec 12, 2024
Contributor
datho7561
left a comment
There was a problem hiding this comment.
This change looks pretty good so far.
I think, if we want to support something like 192.168.1.23:9090 as the proxy, we can use this regex:
(?:https?:\/\/)?([^:/]+)(?::([0-9]+))?
which just wraps the https:// part in a non-capturing group and makes it optional.
From what I can tell, we don't use the http:// or https:// part of the url anyways, so it shouldn't matter if it's left out.
Contributor
Author
|
I have tried the const HOST_AND_PORT_EXTRACTOR = (?:https?://)?([^:/]+)(?::([0-9]+))?; but it seems it is not a valid regexp |
Contributor
|
ahh I think you need to surround it in const HOST_AND_PORT_EXTRACTOR = /(?:https?://)?([^:/]+)(?::([0-9]+))?/; |
Contributor
diff --git a/src/settings/proxySettings.ts b/src/settings/proxySettings.ts
index 3cbcf38..6ee7d0c 100644
--- a/src/settings/proxySettings.ts
+++ b/src/settings/proxySettings.ts
@@ -152,7 +152,7 @@ export function jvmArgsContainsProxySettings(jvmArgs: string): boolean {
);
}
-const HOST_AND_PORT_EXTRACTOR = /https?:\/\/([^:/]+)(?::([0-9]+))?/;
+const HOST_AND_PORT_EXTRACTOR = /(?:https?:\/\/)?([^:/]+)(?::([0-9]+))?/;
const JVM_PROXY_HOST = 'http.proxyHost';
const JVM_PROXY_PORT = 'http.proxyPort'; |
Signed-off-by: azerr <azerr@redhat.com>
6875f50 to
32508ef
Compare
Contributor
Author
|
Thanks @datho7561 ! It seems it is working pretty well. Please merge the PR if you think it is good. |
datho7561
approved these changes
Dec 12, 2024
Contributor
|
Thanks for fixing this, Angelo! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR should fix the following problem:
reported at #154 (comment)
I think to reproduce the problem, proxy address have a wrong format (don't start with
https://)A simple test that I did in debug is: