Skip to content
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

Fix URL parser for parentheses and Chinese Characters #43

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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: 3 additions & 1 deletion example/linkify_example.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:linkify/linkify.dart';

void main() {
print(linkify("Made by https://cretezy.com [email protected]"));
print(linkify(
Copy link
Owner

Choose a reason for hiding this comment

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

Hey, mind reverting this and adding a test instead?

"http://mp.weixin.qq.com/s?__biz=MjM5MTA2ODI3OA==&mid=2449972191&idx=1&sn=0bfa1d94afec30c7113c3881495906ac&chksm=b14802c6863f8bd0d603db6e92fa604c03b98399ae3ccd9fa20db1776210aac90e2165ecde68&mpshare=1&scene=23&srcid=0703HOllo8ED2Ey25CqrKWzM&sharer_sharetime=1625303541359&sharer_shareid=5a67e5ce7f5b1dcf9c5153d2b078e447#rd",
options: LinkifyOptions(humanize: false)));
// Output: [TextElement: 'Made by ', UrlElement: 'https://cretezy.com' (cretezy.com), TextElement: ' ', EmailElement: '[email protected]' ([email protected])]
}
2 changes: 1 addition & 1 deletion lib/src/url.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:linkify/linkify.dart';

final _urlRegex = RegExp(
r'^(.*?)((?:https?:\/\/|www\.)[^\s/$.?#].[^\s]*)',
r'^(.*?)((?:https?:\/\/|www\.)[^\s/$.?#].[\/\\\%:\?=&#@;A-Za-z0-9_.~-]*)',
caseSensitive: false,
dotAll: true,
);
Expand Down
53 changes: 30 additions & 23 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "17.0.0"
version: "22.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.7.0"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.7.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -42,14 +42,14 @@ packages:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.3.1"
collection:
dependency: "direct dev"
description:
Expand All @@ -63,42 +63,49 @@ packages:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
coverage:
dependency: transitive
description:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.3"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
version: "6.1.2"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
http_parser:
dependency: transitive
description:
Expand Down Expand Up @@ -126,7 +133,7 @@ packages:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.0.1"
matcher:
dependency: transitive
description:
Expand All @@ -140,7 +147,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.6.0"
mime:
dependency: transitive
description:
Expand All @@ -154,7 +161,7 @@ packages:
name: node_preamble
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.13"
version: "2.0.1"
package_config:
dependency: transitive
description:
Expand All @@ -175,7 +182,7 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
version: "1.11.1"
pool:
dependency: transitive
description:
Expand All @@ -196,7 +203,7 @@ packages:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.4"
shelf_packages_handler:
dependency: transitive
description:
Expand All @@ -217,7 +224,7 @@ packages:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.0.1"
source_map_stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -273,21 +280,21 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.5"
version: "1.17.9"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.4.1"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.15"
version: "0.3.29"
typed_data:
dependency: transitive
description:
Expand All @@ -301,7 +308,7 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0+1"
version: "7.1.0"
watcher:
dependency: transitive
description:
Expand All @@ -315,7 +322,7 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
webkit_inspection_protocol:
dependency: transitive
description:
Expand Down