Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [unreleased]

### Changes

- Notification links now open in external browser

### Fixed

- Bug fixes and stability improvements
Expand Down
8 changes: 8 additions & 0 deletions src/screens/NotificationDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useLayoutEffect, useRef } from "react";
import { Linking } from "react-native";
import Toast from "react-native-toast-message";
import { WebView } from "react-native-webview";

Expand Down Expand Up @@ -56,6 +57,13 @@ const NotificationDetail: React.FC<Props> = ({ route, navigation }) => {
html: notification?.html ?? "",
}}
textZoom={125}
onShouldStartLoadWithRequest={(event) => {
if (!/^[data:text, about:blank]/.test(event.url)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The regex /^[data:text, about:blank]/ uses a character class [] instead of alternation |. This incorrectly keeps many external URLs inside the WebView.
Severity: HIGH

Suggested Fix

Replace the incorrect character class-based regex with one that uses alternation to match the full schemes. The regex should be changed to /^(data:|about:blank)$/ to correctly match data: or about:blank URLs.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/screens/NotificationDetail.tsx#L61

Potential issue: The regular expression on line 61 uses a character class `[]` which
matches any single character within the set, rather than the intended string literals.
The logic is designed to open URLs in an external browser unless they match the pattern.
Because of the incorrect regex, any URL starting with characters like 'd', 'a', 't', or
'e' (e.g., `docs.gitlab.com`) will be incorrectly trapped within the WebView instead of
opening externally. This defeats the primary purpose of the feature, which is to open
notification links in an external browser.

Did we get this right? 👍 / 👎 to inform future reviews.

Linking.openURL(event.url);
return false;
}
return true;
}}
/>
);
};
Expand Down
Loading