-
Notifications
You must be signed in to change notification settings - Fork 135
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
Krishna2323/issue/49286 #813
Krishna2323/issue/49286 #813
Conversation
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
lib/str.ts
Outdated
* @returns The formatted URL | ||
*/ | ||
sanitizeURL(url: string): string { | ||
sanitizeURL(url: string, scheme = 'https'): string { |
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.
sanitizeURL(url: string, scheme = 'https'): string { | |
sanitizeURL(url: string, defaultScheme = 'https'): string { |
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 defaultScheme
is more meaningful because it uses only as a default value if the URL didn't have a scheme. We also need to update the comment and its usage.
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 can also add a unit to confirm that
expect(Str.sanitizeURL('https://example.com', 'http')).toBe('https://example.com');
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.
done.
@rlinoz I'll take over as I'm assigned to the parent issue |
@Krishna2323 bump for the above review |
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
__tests__/Str-test.js
Outdated
expect(Str.sanitizeURL('FOO.com/blah_BLAH')).toBe('https://foo.com/blah_BLAH'); | ||
+expect(Str.sanitizeURL('FOO.com/blah_BLAH', 'http')).toBe('http://foo.com/blah_BLAH'); | ||
+expect(Str.sanitizeURL('example.com', 'http')).toBe('http://example.com'); | ||
expect(Str.sanitizeURL('https://example.com', 'http')).toBe('http://example.com'); |
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.
expect(Str.sanitizeURL('https://example.com', 'http')).toBe('http://example.com'); | |
expect(Str.sanitizeURL('https://example.com', 'http')).toBe('https://example.com'); |
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.
@Krishna2323 Let's finish 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.
done
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
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.
LGTM!
Fixed Issues
$ GH_LINK Expensify/App#49286
Details: This PR updates the
sanitizeURL
utility function to accept a new parameter,scheme
. Thescheme
parameter allows us to specify the scheme as needed. The default value ishttps
, but we can passhttp
or any other scheme as the scheme parameter to override it.Tests
QA