Skip to content

Commit 6c1dc76

Browse files
authored
fix: weburl regex (#162)
1 parent f0e6db5 commit 6c1dc76

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/ExpoShareIntentModule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type ExpoShareIntentModuleEvents = {
1515
declare class ExpoShareIntentModuleType extends NativeModule<ExpoShareIntentModuleEvents> {
1616
getShareIntent(url: string): string;
1717
clearShareIntent(key: string): Promise<void>;
18-
hasShareIntent(key: string): Promise<boolean>;
18+
hasShareIntent(key: string): boolean;
1919
}
2020

2121
// Import the native module. it will be resolved on native platforms to ExpoShareIntentModule.ts

src/utils.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ export const parseShareIntent = (
8585
if (shareIntent?.text) {
8686
// Try to find the webURL in the SharedIntent text
8787
const webUrl =
88-
shareIntent.text.match(
89-
/[(http(s)?)://(www.)?-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/gi,
90-
)?.[0] || null;
88+
shareIntent.text
89+
.match(
90+
/[(http(s)?)://(www.)?-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/gi,
91+
)
92+
?.find((link) => link.startsWith("http")) || null;
9193

9294
result = {
9395
...SHAREINTENT_DEFAULTVALUE,

0 commit comments

Comments
 (0)