diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-02 00:09:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-02 00:09:22 +0300 |
commit | c25993c0fc4bee979facf97b38f270c8fd15bd47 (patch) | |
tree | 5a3d9301871b7350737197d90af82264a82897cb /app/assets/javascripts/gfm_auto_complete.js | |
parent | fb7b3d71b179f877dca72d86eccf29eeb9f883b7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/gfm_auto_complete.js')
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js index bd87d0df01a..0e33c712470 100644 --- a/app/assets/javascripts/gfm_auto_complete.js +++ b/app/assets/javascripts/gfm_auto_complete.js @@ -254,10 +254,18 @@ class GfmAutoComplete { callbacks: { ...this.getDefaultCallbacks(), matcher(flag, subtext) { - const regexp = new RegExp(`(?:[^${glRegexp.unicodeLetters}0-9:]|\n|^):([^:]*)$`, 'gi'); + const regexp = new RegExp( + `(?:[^${glRegexp.unicodeLetters}0-9:]|\n|^):([^ :][^:]*)?$`, + 'gi', + ); const match = regexp.exec(subtext); - return match && match.length ? match[1] : null; + if (match && match.length) { + // Since we have "?" on the group, it's possible it is undefined + return match[1] || ''; + } + + return null; }, filter(query, items) { if (GfmAutoComplete.isLoading(items)) { |