Skip to content

Commit

Permalink
Merge pull request #754 from geonetwork/DH/fix-link-detection
Browse files Browse the repository at this point in the history
[Datahub] Fix : Improve linkify REGEX
  • Loading branch information
cmoinier authored Jan 9, 2024
2 parents 5281d0d + 4c0daff commit 513ce2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const testingUrls = [
'Thirteenth link http://foo.com/(something)?after=parens query params',
'http://foo.com/(something)?after=parens',
],
[
'Fourteenth link (http://foo.com/blah) in parenthesis',
'http://foo.com/blah',
],
]

const testWithMultipleUrls = {
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/elements/src/lib/metadata-info/linkify.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export class GnUiLinkifyDirective implements OnInit {
if (url) {
displayValue = this.createLink(displayValue, url)
} else {
const urlRegex = /\bhttps?:\/\/\S+\b[=)/]?/g
const matches = displayValue.match(urlRegex)
const urlRegex = /\bhttps?:\/\/(?:\([^\s()]+\)|[^\s()]+)+/g

const matches = displayValue.match(urlRegex)
if (matches && matches.length > 0) {
matches.forEach((match) => {
url = match
Expand Down

0 comments on commit 513ce2f

Please sign in to comment.