-
Notifications
You must be signed in to change notification settings - Fork 855
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
[MM-53799] Stop autocompleting while the user is typing https://
#3202
Conversation
src/app/serverViewState.ts
Outdated
httpUrl = url.replace(/^((.+):\/\/)?/, 'https://'); | ||
} else { | ||
// Otherwise add HTTPS for them | ||
} else if (!url.match(/^(h|ht|htt|http|https):?\/?\/?$/)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of regexes. It's probably easier to write a quick sub-string prefix matching function that does this. 0/5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this is less code though, because then i'd have to check all of the above cases for substrings and it would be a mess of ORs. I usually try to avoid regexes as well these days, but I think for this it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could flip the check around? Something like 'https://'.startsWith(url)
seems like it would work, although we'd have to check both HTTP and HTTPS separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant a generic function, not a mess of ORs ;) But looks like Harrison's suggestion would work as well. Checking for both http and https doesn't sound like too much overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harrison's solution sounds very clean so yes I will implement that instead.
Here are the test results below: Test Summary for Linux on commit 8fb3ac4The following known failed tests have been fixed on Linux: Test Summary for macOS on commit 8fb3ac4New failed tests found on macOS:
The following known failed tests have been fixed on macOS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be a rare cases, that can occur when typing
- typing Capital HTTPS, changes it into lower and adds https
- typing
https
and appending special charecters like"
,'
will quickly parse it and append https. (for other special charecters it doent do this)
Verified creating, editing server url that when typing https
the input field wont append additional https
unless user types some other word
Will make a fix for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary
In circumstances where the user stopped typing, or was slow typing the beginning of their server URL, the URL validation would kick in and erroneously mistake the beginning of a URL (ie. any substring of
https://
) as a hostname, and try to addhttps://
for the user. This would cause some confusion and frustration for users trying to type.This PR fixes the validation to recognize any leading substring of
https://
as an invalid URL before it tries to call it a hostname. This stops the user from having to backspace and correct themselves while typing, and should still server to help people typing without the leadinghttps://
. Additionally, I added a QoL fix to stop the trailing/
from appearing while you were typing a host name, so that if you do stop, you don't have to backspace the/
first to keep typing the name.Ticket Link
https://mattermost.atlassian.net/browse/MM-53799