From aeebe85308508b9b9855af3e4ebd08a5d8a30d09 Mon Sep 17 00:00:00 2001 From: David Celis Date: Tue, 10 Dec 2013 12:34:37 -0800 Subject: [PATCH] Do not githubify sign-off messages Don't successfully `githubify` strings prepended with an `@` symbol if what's matched actually resembles an email address. @mentions should only be githubified if there is a word boundary before it. This fixes travis-ci/travis-ci#1591 Signed-off-by: David Celis --- assets/scripts/app/helpers/helpers.coffee | 2 +- assets/scripts/spec/unit/helpers_spec.coffee | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/scripts/app/helpers/helpers.coffee b/assets/scripts/app/helpers/helpers.coffee index 53daa7b6..ea892a81 100644 --- a/assets/scripts/app/helpers/helpers.coffee +++ b/assets/scripts/app/helpers/helpers.coffee @@ -84,7 +84,7 @@ require 'config/emoij' _githubReferenceRegexp: new RegExp("([\\w-]+)?\\/?([\\w-]+)?(?:#|gh-)(\\d+)", 'g') - _githubUserRegexp: new RegExp("@([\\w-]+)", 'g') + _githubUserRegexp: new RegExp("^|\\B@([\\w-]+)", 'g') _githubUserLink: (reference, username) -> "#{reference}" diff --git a/assets/scripts/spec/unit/helpers_spec.coffee b/assets/scripts/spec/unit/helpers_spec.coffee index 829c8a13..fe049984 100644 --- a/assets/scripts/spec/unit/helpers_spec.coffee +++ b/assets/scripts/spec/unit/helpers_spec.coffee @@ -52,3 +52,9 @@ test 'replaces @user with github user link', -> expected = 'It is for you @tender_love1' equal(result, expected, "@user should be converted to a link") + +test 'does not replace @user if it is a sign-off', -> + message = 'Signed-off-by: GitHub User ' + result = Travis.Helpers.githubify(message, 'travis-ci', 'travis-web') + + equal(result, message, "@user should not be converted to a link if it matches an email")