From: dklawren Date: Thu, 29 Aug 2019 13:38:13 +0000 (-0400) Subject: Bug 1575003 - Can't link to gitlab issues in the "see also" field X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3751928389c0062877ac23b5040226f849a88cfd;p=thirdparty%2Fbugzilla.git Bug 1575003 - Can't link to gitlab issues in the "see also" field --- diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index ff2da1be6..b1dec460f 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -65,6 +65,7 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::MantisBT Bugzilla::BugUrl::SourceForge Bugzilla::BugUrl::GitHub + Bugzilla::BugUrl::GitLab Bugzilla::BugUrl::MozSupport Bugzilla::BugUrl::Aha Bugzilla::BugUrl::WebCompat diff --git a/Bugzilla/BugUrl/GitLab.pm b/Bugzilla/BugUrl/GitLab.pm new file mode 100644 index 000000000..8e546c1dc --- /dev/null +++ b/Bugzilla/BugUrl/GitLab.pm @@ -0,0 +1,45 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::BugUrl::GitLab; + +use 5.10.1; +use strict; +use warnings; + +use base qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + +# GitLab issue URLs can have the form: +# https://gitlab.com/projectA/subprojectB/subprojectC/../issues/53 + return ($uri->path =~ m!^/.*/issues/\d+$!) ? 1 : 0; +} + +sub _check_value { + my ($class, $uri) = @_; + + $uri = $class->SUPER::_check_value($uri); + + # Require the HTTPS scheme. + $uri->scheme('https'); + + # Make sure there are no query parameters. + $uri->query(undef); + + # And remove any # part if there is one. + $uri->fragment(undef); + + return $uri; +} + +1;