Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-webui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Commits
5ff3834b
Commit
5ff3834b
authored
1 year ago
by
Joscha Schmiedt
Browse files
Options
Downloads
Patches
Plain Diff
Add a better regex for linkify
parent
7060ed2c
No related branches found
No related tags found
2 merge requests
!131
FIX: error in regexp to match URLs
,
!128
F 344 extern linkify absorbs commas etc into link adress
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/js/ext_cosmetics.js
+4
-1
4 additions, 1 deletion
src/core/js/ext_cosmetics.js
with
4 additions
and
1 deletion
src/core/js/ext_cosmetics.js
+
4
−
1
View file @
5ff3834b
...
@@ -68,7 +68,10 @@ var cosmetics = new function () {
...
@@ -68,7 +68,10 @@ var cosmetics = new function () {
* @returns {string} text with <a> elements instead of raw links
* @returns {string} text with <a> elements instead of raw links
*/
*/
function
linkify_string
(
text
)
{
function
linkify_string
(
text
)
{
const
match_url_regex
=
/https
?
:
\/\/[^\s]
*
\b(?![
,:;?!
])
/gi
;
// const match_url_regex = /https?:\/\/[^\s]*/g // original
// https://regexr.com helps you design regex
const
match_url_regex
=
/https
?
:
\/\/(
www
\.)?[
-a-zA-Z0-9@:%._
\+
~#=
]{1,256}\.?[
a-zA-Z0-9()
]{1,6}\b([
-a-zA-Z0-9()@:%_
\+
.~#?&
//
=
]
*
)
/g
return
text
.
replace
(
match_url_regex
,
function
(
href
)
{
return
text
.
replace
(
match_url_regex
,
function
(
href
)
{
var
link_text
=
href
;
var
link_text
=
href
;
if
(
_link_cut_off_length
>
4
&&
link_text
.
length
>
_link_cut_off_length
)
{
if
(
_link_cut_off_length
>
4
&&
link_text
.
length
>
_link_cut_off_length
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment