Google.pm 1.12 KB
Newer Older
1 2 3
# 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/.
4
#
5 6
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
7 8 9 10 11 12 13 14 15 16 17

package Bugzilla::BugUrl::Google;
use strict;
use base qw(Bugzilla::BugUrl);

###############################
####        Methods        ####
###############################

sub should_handle {
    my ($class, $uri) = @_;
18 19 20

    # Google Code URLs only have one form:
    #   http(s)://code.google.com/p/PROJECT_NAME/issues/detail?id=1234
21
    return (lc($uri->authority) eq 'code.google.com'
22 23
            and $uri->path =~ m|^/p/[^/]+/issues/detail$|
            and $uri->query_param('id') =~ /^\d+$/) ? 1 : 0;
24 25 26 27 28 29 30 31 32
}

sub _check_value {
    my ($class, $uri) = @_;
    
    $uri = $class->SUPER::_check_value($uri);

    # While Google Code URLs can be either HTTP or HTTPS,
    # always go with the HTTP scheme, as that's the default.
33 34 35
    if ($uri->scheme eq 'https') {
        $uri->scheme('http');
    }
36

37
    return $uri;
38 39 40
}

1;