From 2d8badfce2364ffe22bbd8448e7a74bbccba10c7 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 17 Mar 2015 12:13:48 +0800 Subject: Bug 1132963: Automatically detect and redirect to Google doc URLs (akin to github-pr and rb handling) --- extensions/BMO/lib/Data.pm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'extensions/BMO/lib/Data.pm') diff --git a/extensions/BMO/lib/Data.pm b/extensions/BMO/lib/Data.pm index dc091d23c..63d0eb4ad 100644 --- a/extensions/BMO/lib/Data.pm +++ b/extensions/BMO/lib/Data.pm @@ -19,11 +19,25 @@ our @EXPORT = qw( $cf_visible_in_products %product_sec_groups %create_bug_formats @default_named_queries - GITHUB_PR_CONTENT_TYPE - RB_REQUEST_CONTENT_TYPE ); + %autodetect_attach_urls ); -use constant GITHUB_PR_CONTENT_TYPE => 'text/x-github-pull-request'; -use constant RB_REQUEST_CONTENT_TYPE => 'text/x-review-board-request'; +# Creating an attachment whose contents is a URL matching one of these regexes +# will result in the user being redirected to that URL when viewing the +# attachment. +our %autodetect_attach_urls = ( + github_pr => { + regex => qr#^https://github\.com/[^/]+/[^/]+/pull/\d+/?$#i, + content_type => 'text/x-github-pull-request', + }, + reviewboard => { + regex => qr#^https?://reviewboard(?:-dev)?\.(?:allizom|mozilla)\.org/r/\d+/?#i, + content_type => 'text/x-review-board-request', + }, + google_docs => { + regex => qr#^https://docs\.google\.com/(?:document|spreadsheets|presentation)/d/#i, + content_type => 'text/x-google-doc', + }, +); # Which custom fields are visible in which products and components. # -- cgit v1.2.3-24-g4f1b