michael-s-molina commented on code in PR #20890:
URL: https://github.com/apache/superset/pull/20890#discussion_r933522732
##########
superset-frontend/src/components/GenericLink/GenericLink.tsx:
##########
@@ -29,9 +30,9 @@ export const GenericLink = <S,>({
...rest
}: React.PropsWithoutRef<LinkProps<S>> &
React.RefAttributes<HTMLAnchorElement>) => {
- if (typeof to === 'string' && /^https?:\/\//.test(to)) {
+ if (typeof to === 'string' && isUrlExternal(to)) {
return (
- <a data-test="external-link" href={to} {...rest}>
+ <a data-test="external-link" href={parseUrl(to)} {...rest}>
Review Comment:
Small suggestion for a follow-up: You could return the parsed value when
it's valid and undefined or another thing when it's invalid. That way you would
only need to apply the regex once by combining `isUrlExternal` with `parseUrl`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]