-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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/11810 old dot link without w3 not auto signin #12701
Fix/11810 old dot link without w3 not auto signin #12701
Conversation
src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js
Outdated
Show resolved
Hide resolved
Hi @parasharrajat @MonilBhavsar I just fixed your comments and added unit test. Please help to check again. Thanks |
I will test it shortly. Can you please look into #12701 (comment)? |
Bump @tienifr above. |
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.
Add another test.
it('It should work correctly without https://', () => {
expect(Url.hasSameOrigin('new.expensify.com/action/1234', 'new.expensify.com/action/123')).toBe(true);
});
it should also pass.
Let's add tests for all urls in https://github.com/Expensify/expensify-common/blob/dd66d931aeffe18cdcffab8e7d05af32f3ef7ad1/__tests__/ExpensiMark-HTML-test.js#L178 for URL.getURLObject
.
you can drop the similar urls.
If tests are not passing for these URLs then I feel like It might cause issues in the future and additional maintenance costs to manage it. @MonilBhavsar What do you think? Should we keep it and just fix this issue? Or limit this function to more strict expensify URLs only |
Agree, function should be able to parse all kind of valid URLs. let's add tests for all valid URLs |
…ttps://github.com/tienifr/App into fix/11810-old-dot-link-without-w3-not-auto-signin
Hi @MonilBhavsar @parasharrajat sorry about my late. I just added UTs and fixed your comments, please help to check again. Thanks |
src/libs/Url.js
Outdated
*/ | ||
function getURLObject(href) { | ||
const urlRegex = new RegExp([ | ||
'^(https?:)//', // 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 still feel like we need to update this regex as it doesn't parse URL's without http 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.
can we use the regex from ExpensiMark.js
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.
You wanted to link this - https://github.com/Expensify/expensify-common/blob/dd66d931aeffe18cdcffab8e7d05af32f3ef7ad1/lib/ExpensiMark.js#L5?
If yes, sounds good 👍
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.
Yeah, that one. Thanks.
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.
@parasharrajat @MonilBhavsar Thanks for your review, but I'm afraid that we have no way to import URL_WEBSITE_REGEX
from ExpensiMark
. Should I duplicate URL_WEBSITE_REGEX
and TLD_REGEX
or fix on upstream.
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 would say fix on upstream. @parasharrajat what do you think?
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.
yeah, feel free to send a PR to expose the data from the e-common repo. https://github.com/Expensify/expensify-common
Create a new File to hold the URL const and import that in ExpensiMark.
Thanks @parasharrajat @MonilBhavsar, I agree with you. Should I split the hostname by dot then ignore www if the result has 3 elements and starts with www? But there're some special cases like: www.example.co.uk. Actually we have several libs to detect the subdomain (pls), but I think adding the new lib is not necessary. Pls let me know your thought. |
Hmm, these special cases are making it complex. I would say we simply fix this issue and ignore a generic solutions for now. Let's modify the Also, leave a comment specifying the edge case which prevented us from making it generic. @tienifr Do you still see some cases where this will fail in our app? Please let me know if I am not seeing any. |
Sounds good 👍 Let's just fix this issue with |
@parasharrajat @MonilBhavsar Thanks for your review, I've changed my PR to update |
src/libs/Url.js
Outdated
function shouldRemoveW3(hostname) { | ||
const parts = hostname.split('.').reverse(); | ||
const subDomain = parts[2]; | ||
return subDomain === 'www'; | ||
} |
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.
It is good to create a separate function for this but there is not base for the logic used in this. why are we checking parts[2] for subdomain? URL can be very versatile. That's why I suggest you just move this logic inside hasSameExpensifyOrigin
so that it is clear that subDomain === 'www'
is applicable to Expensify domains.
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 have www.new.expensify.com => hostname.split('.').reverse() = [com,expensify,new,www] that why I use parts[2] (new) for subdomain. I'm also afraid of duplicating this logic inside hasSameExpensifyOrigin
so I created a separate function.
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.
Can we use shouldRemoveW3FromExpensifyUrl?
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.
Yeah, I didn't notice there are two calls to it. Yeah that will work.
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.
@parasharrajat I've changed my PR. Pls help check, thanks
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.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issues
section above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Tests
section - I verified the steps for Staging and/or Production testing are in the
QA steps
section - I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- I verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified tests pass on all platforms & I tested again on:
- iOS / native
- Android / native
- iOS / Safari
- Android / Chrome
- MacOS / Chrome
- MacOS / Desktop
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (see Reviewing the code)
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReport
and notonIconClick
). - I verified that comments were added to code that is not self explanatory
- I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- I verified any copy / text shown in the product was added in all
src/languages/*
files - I verified any copy / text that was added to the app is correct English and approved by marketing by adding the
Waiting for Copy
label for a copy review on the original GH to get the correct copy. - I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
- I verified the JSDocs style guidelines (in
STYLE.md
) were followed
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar
, I verified the components usingAvatar
have been tested & I retested again) - I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately and each prop has a
/** comment above it */
- The file is named correctly
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- For Class Components, any internal methods passed to components event handlers are bound to
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor) - Any internal methods bound to
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
) - All JSX used for rendering exists in the render method
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- If a new CSS style is added I verified that:
- A similar style doesn't already exist
- The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)
- If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avatar
is modified, I verified thatAvatar
is working as expected in all cases) - If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
cc: @MonilBhavsar
🎀 👀 🎀 C+ reviewed
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.
Also, please add tests to cover broader case. You can add more variations of URL's.
const internalNewExpensifyPath = (Url.hasSameExpensifyOrigin(attrHref, CONST.NEW_EXPENSIFY_URL) || Url.hasSameExpensifyOrigin(attrHref, CONST.STAGING_NEW_EXPENSIFY_URL)) && attrPath; | ||
const internalExpensifyPath = Url.hasSameExpensifyOrigin(attrHref, CONFIG.EXPENSIFY.EXPENSIFY_URL) | ||
&& !attrPath.startsWith(CONFIG.EXPENSIFY.CONCIERGE_URL_PATHNAME) | ||
&& attrPath; |
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.
Check for attrPath
before
attrPath && !attrPath.startsWith(CONFIG.EXPENSIFY.CONCIERGE_URL_PATHNAME)
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 Sorry I don't understand your mean. If we use check attrPath before attrPath && !attrPath.startsWith(CONFIG.EXPENSIFY.CONCIERGE_URL_PATHNAME)
=> internalExpensifyPath will be boolean
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.
Ah ok, got it
} | ||
|
||
/** | ||
* Determine if we should remove w3 from hostname |
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.
Lets update the comment to answer - Why we want to remove sub domain
* @param {String} hostname | ||
* @returns {Boolean} | ||
*/ | ||
function shouldRemoveW3FromExpensifyUrl(hostname) { |
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.
Ah, also this function is not working as expected, locally. I mean for internal engineers as our local URL has subdomain and can be accessed with both www and now www - expensify.com.dev
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.
@parasharrajat This is exactly what we mentioned before #12701 (comment) and I think we should find the generic solution right?
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'm so appreciated if we had the regex for this case before. If not I'll find by myself. Thanks
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 am really confused and not sure how can we fix this problem once and for all. Should we keep a list of URLs that support www
and adjust this function?
@MonilBhavsar I think we need internal support here.
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 feel like this is an exceptional case and we can add a condition to support 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.
@MonilBhavsar You mean if hostname === 'www.expensify.com.dev'
we will remove www.
first then keep the logic to remove www as before right?
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.
Correct!
Also please leave a comment, why are we doing like this. Something like -
Since expensify.com.dev is accessible with and without www subdomain.
cc: @tienifr This is very close to merging. Let's wrap this up. |
@parasharrajat @MonilBhavsar Thanks for your help. I've updated my PR to add more tests with local url and update logic to remove w3 from local expensify url |
@MonilBhavsar All yours.. |
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.
Also, please add tests to cover broader case. You can add more variations of URL's.
@tienifr please update tests and QA to cover different URL variations and also concierge path case
@MonilBhavsar Please help to check again. Thanks |
Thanks! updated one link - https://new.expensify.com/inbox because there is no inbox in newdot |
The PR author checklist is failing, could you please check again |
You may have to get the latest PR Author checklist from https://github.com/Expensify/App/blob/main/.github/PULL_REQUEST_TEMPLATE.md and replace PR description with that. |
Hi @MonilBhavsar , Please help to check again. Thanks cc @parasharrajat |
Performance Comparison Report 📊Significant Changes To DurationThere are no entries Meaningless Changes To DurationShow entries
Show details
|
🚀 Deployed to production by @chiragsalian in version: 1.2.40-3 🚀
|
Details
In new dot Expensify, when sending old dot link without ‘www.’ prefix it is redirecting to enter password screen and expectation is automatically signed in to old dot.. This PR will fix that
Fixed Issues
$ #11810
$ #11810 (comment)
Tests
Offline tests
QA Steps
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.PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesWaiting 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
have been tested & I retested again)/** 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)Screenshots
Web
Screen.Recording.2022-11-14.at.17.15.00.mp4
Mobile Web - Chrome
old.mp4
Mobile Web - Safari
Can not click URL on Safari (even though in main branch)
Desktop
Screen.Recording.2022-11-14.at.16.58.56.mp4
iOS
Screen.Recording.2022-11-14.at.17.18.29.mp4
Android
Screen.Recording.2022-11-14.at.17.24.24.mp4