-
Notifications
You must be signed in to change notification settings - Fork 90
Fixing Linking on urls #172
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
Conversation
- Ignore email address from generating og preview - sanitize the urls before using Linking module from react-native
src/components/StatusUpdateForm.js
Outdated
| const urlRegex = /(?:[\w/:@-]+\.[\w/:@.-]*)+(?=\s|$)/g; | ||
| const emailRegex = /.*@.*/ ; |
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.
In discussion with Anatoly, for better regex!! Will replace it!
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.
what if the url has an @ in the query params for some reason?
src/utils.js
Outdated
|
|
||
| // https://reactnative.dev/docs/linking | ||
| export const sanitizeUrlForLinking = (url) => { | ||
| if (url.indexOf('http://') === -1 && url.indexOf('https://') === -1) { |
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.
pretty much the same thing
| if (url.indexOf('http://') === -1 && url.indexOf('https://') === -1) { | |
| if (!/^https?:\/\//.test(url)) { |
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.
Apparently there is http.com lol, so wanted to avoid that!!
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.
alright updated it with regex
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 alot @virdesai :)
src/components/StatusUpdateForm.js
Outdated
| const urlRegex = /(?:[\w/:@-]+\.[\w/:@.-]*)+(?=\s|$)/g; | ||
| const emailRegex = /.*@.*/ ; |
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.
what if the url has an @ in the query params for some reason?
7bd4e5a to
c1178d8
Compare
|
|
||
| const urlRegex = /(https?:\/\/[^\s]+)/gi; | ||
|
|
||
| const urlRegex = /(?:\s|^)((?:https?:\/\/)?(?:[a-z0-9-]+(?:\.[a-z0-9-]+)+)(?::[0-9]+)?(?:\/(?:[^\s]+)?)?)/g; |
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 to @AnatolyRugalev !! Works pretty well - https://regex101.com/r/3ms9WF/1/
Related ZD #9383
Fixes