diff options
-rw-r--r-- | Bugzilla/BugUrl.pm | 1 | ||||
-rw-r--r-- | Bugzilla/BugUrl/GitLab.pm | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 5d62d1b17..42e993bf4 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 ); ############################### 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; |