Skip to content

Commit

Permalink
fix: inability to handle long URLs with params properly when clicked …
Browse files Browse the repository at this point in the history
…on message (#2321)

* fix: inability to handle long URLs with params properly when clicked on message

* fix: add comments for the change
  • Loading branch information
khushal87 committed Nov 23, 2023
1 parent e0dbfae commit 8cbc927
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,17 @@ export const renderText = <
: Linking.canOpenURL(url).then((canOpenUrl) => canOpenUrl && Linking.openURL(url));
};

let previousLink: string | undefined;
const linkReact: ReactNodeOutput = (node, output, { ...state }) => {
const url = node.target;
let url: string;
// Some long URLs with `&` separated parameters are trimmed and the url only until first param is taken.
// This is done because of internal link been taken from the original URL in react-native-markdown-package. So, we check for `withinLink` and take the previous full URL.
if (state?.withinLink && previousLink) {
url = previousLink;
} else {
url = node.target;
previousLink = node.target;
}
const onPress = (event: GestureResponderEvent) => {
if (!preventPress && onPressParam) {
onPressParam({
Expand Down

0 comments on commit 8cbc927

Please sign in to comment.