Skip to content

Commit

Permalink
Merge pull request #43997 from nextcloud/fix/url_regex
Browse files Browse the repository at this point in the history
fix: Make URL pattern regexes match localhost and URLs with ports
  • Loading branch information
mejo- committed Mar 6, 2024
2 parents 0a64b69 + ea7a695 commit 782f808
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/OCP/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import $ from 'jquery'
*
* This is a copy of the backend regex in IURLGenerator, make sure to adjust both when changing
*/
const urlRegex = /(\s|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig
const urlRegex = /(\s|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig

/**
* @param {any} content -
Expand Down
4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/public/IURLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface IURLGenerator {
*
* @since 25.0.0
*/
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';

/**
* Returns the URL for a route
Expand Down

0 comments on commit 782f808

Please sign in to comment.