summaryrefslogtreecommitdiffstats
path: root/Bugzilla/BugUrl/Launchpad.pm
diff options
context:
space:
mode:
authorMatt Selsky <selsky@columbia.edu>2012-06-17 14:19:09 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-06-17 14:19:09 +0200
commit4c236f418a7122cecd22c36c679a7b9faf5469f7 (patch)
tree93326ee30db6f08ef84a99f74fdb8f6fea3e9d8e /Bugzilla/BugUrl/Launchpad.pm
parent35bf9943a87018e6cfa2d49f83f77c22205ddfc0 (diff)
downloadbugzilla-4c236f418a7122cecd22c36c679a7b9faf5469f7.tar.gz
bugzilla-4c236f418a7122cecd22c36c679a7b9faf5469f7.tar.xz
Bug 759030: Clean up Bugzilla::BugUrl modules
r=timello a=LpSolit
Diffstat (limited to 'Bugzilla/BugUrl/Launchpad.pm')
-rw-r--r--Bugzilla/BugUrl/Launchpad.pm31
1 files changed, 13 insertions, 18 deletions
diff --git a/Bugzilla/BugUrl/Launchpad.pm b/Bugzilla/BugUrl/Launchpad.pm
index 37a238be4..87fb71a5d 100644
--- a/Bugzilla/BugUrl/Launchpad.pm
+++ b/Bugzilla/BugUrl/Launchpad.pm
@@ -9,15 +9,19 @@ package Bugzilla::BugUrl::Launchpad;
use strict;
use base qw(Bugzilla::BugUrl);
-use Bugzilla::Error;
-
###############################
#### Methods ####
###############################
sub should_handle {
my ($class, $uri) = @_;
- return ($uri->authority =~ /launchpad.net$/) ? 1 : 0;
+
+ # Launchpad bug URLs can look like various things:
+ # https://bugs.launchpad.net/ubuntu/+bug/1234
+ # https://launchpad.net/bugs/1234
+ # All variations end with either "/bugs/1234" or "/+bug/1234"
+ return ($uri->authority =~ /launchpad.net$/
+ and $uri->path =~ m|bugs?/\d+$|) ? 1 : 0;
}
sub _check_value {
@@ -25,21 +29,12 @@ sub _check_value {
$uri = $class->SUPER::_check_value($uri);
- my $value = $uri->as_string;
- # Launchpad bug URLs can look like various things:
- # https://bugs.launchpad.net/ubuntu/+bug/1234
- # https://launchpad.net/bugs/1234
- # All variations end with either "/bugs/1234" or "/+bug/1234"
- if ($uri->path =~ m|bugs?/(\d+)$|) {
- # This is the shortest standard URL form for Launchpad bugs,
- # and so we reduce all URLs to this.
- $value = "https://launchpad.net/bugs/$1";
- }
- else {
- ThrowUserError('bug_url_invalid', { url => $value, reason => 'id' });
- }
-
- return new URI($value);
+ # This is the shortest standard URL form for Launchpad bugs,
+ # and so we reduce all URLs to this.
+ $uri->path =~ m|bugs?/(\d+)$|;
+ $uri = new URI("https://launchpad.net/bugs/$1");
+
+ return $uri;
}
1;