]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1575003 - Can't link to gitlab issues in the "see also" field
authordklawren <dklawren@users.noreply.github.com>
Thu, 29 Aug 2019 13:38:13 +0000 (09:38 -0400)
committerGitHub <noreply@github.com>
Thu, 29 Aug 2019 13:38:13 +0000 (09:38 -0400)
Bugzilla/BugUrl.pm
Bugzilla/BugUrl/GitLab.pm [new file with mode: 0644]

index ff2da1be6ad7870eb4002099afa7e167d7f0e700..b1dec460f80341919be2d3e10d5d623a32643298 100644 (file)
@@ -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 (file)
index 0000000..8e546c1
--- /dev/null
@@ -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;