-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: standardise the usage of url validator #17564
Conversation
Initially, I proposed to include Also, our tests were considering a URL without Furthermore, the tests were considering For now, I've fixed the above mentioned anomalies in the test. If everyone agrees here, I'll open a PR in |
@puneetlath @thesahindia One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
I've actually created draft PR in
|
Ok, cool. I think those changes make sense. So we should make the expensify-common update first and then use this PR to up the expensify-common version used in App, yeah? |
@puneetlath Yes. That makes more sense! |
tests/unit/ValidationUtilsTest.js
Outdated
test('Invalid URLs without protocols', () => { | ||
expect(ValidationUtils.isValidWebsite('www.expensify.com')).toBe(false); | ||
expect(ValidationUtils.isValidWebsite('expensify.com')).toBe(false); | ||
test('Valid URLs without protocols', () => { |
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.
We need websites with a valid protocol, so this is invalid.
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.
http, https, ftp are valid protocols accepted by the server as a part of form validation, so In company information step, websites without protocols won't be considered as valid
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.
@MonilBhavsar I'm just trying to be consistent here with the regex that we have in expensify-common
library for URL validation.
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.
The protocol part is optional in that regex. Please take a look Expensify/expensify-common#519.
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.
Hmm, i think we need to be bit strict with URLs that we accept as a part of setting up accounts, and align with server side validation. whereas we can consider a URL with or without protocol a URL when sending/viewing a simple chat message.
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.
Hm... Are we sure that we need the protocol to be present with URLs? Because, at a lot of different apps, I don't think its needed.
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.
@puneetlath @thesahindia Can I get your input here as well? If we're to make the protocol required, then I think I'll need to export the URL
regex defined in the expensify-common
lib without the protocol.
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 think yes, when setting up a bank account. In fact we have that validation currently.
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.
Could you please add automated tests and include website that is failing validation in the issue and include some other similar websites too.
Sure @MonilBhavsar. I'll add it once Expensify/expensify-common#519 gets merged. |
This reverts commit 33f90d4.
@thesahindia @puneetlath This is ready for review now. @MonilBhavsar I've added unit tests for the failing website as well. |
Reviewer Checklist
Screenshots/Videos |
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.
Works well for me!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.3.7-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.7-3 🚀
|
Details
This PR fixes the broken URL validation while adding a bank account. Instead of using a new Regex to validate the URL, I'm making use of the existing one in the
expensify-common
library.Fixed Issues
$ #17205
PROPOSAL: #17205 (comment)
Tests
Verify that error shows up correctly stating the URL as invalid.
Offline tests
N/A
QA Steps
Verify that error shows up correctly stating the URL as invalid.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-04-18.at.11.45.11.AM.mov
Mobile Web - Chrome
Screen.Recording.2023-04-18.at.11.47.42.AM.mov
Mobile Web - Safari
Screen.Recording.2023-04-18.at.11.48.57.AM.mov
Desktop
Screen.Recording.2023-04-18.at.11.46.16.AM.mov
iOS
Screen.Recording.2023-04-18.at.12.45.05.PM.mov
Android
Screen.Recording.2023-04-18.at.11.50.20.AM.mov