app/models/project.rb
# Does this contain a URL *anywhere* in the (justification) text?
# Note: This regex needs to be logically the same as the one used in the
# client-side badge calculation, or it may confuse some users.
# See app/assets/javascripts/*.js function "containsURL".
#
# Note that we do NOT need to validate these URLs, because the BadgeApp
# 1. escapes these (as part of normal processing) against XSS attacks, and
# 2. does not traverse these URLs in its automated processing.
# Thus, this rule is intentionally *not* strict at all.  Contrast this
# with the intentionally strict validation of the project and repo URLs,
# which *are* traversed by BadgeApp and thus need to be much more strict.
#
Does this contain a URL *anywhere* in the (justification) text.
Note: This regex needs to be logically the same as the one used in the
client-side badge calculation, or it may confuse some users.

Note that we do NOT need to validate these URLs, because the BadgeApp
1. escapes these (as part of normal processing) against XSS attacks, and
2. does not traverse these URLs in its automated processing.
Thus, this rule is intentionally *not* strict at all.  Contrast this
with the intentionally strict validation of the project and repo URLs,
which *are* traversed by BadgeApp and thus need to be much more strict.
Does this contain a URL * anywhere * in the ( justification ) text . Note : This regex needs to be logically the same as the one used in the client - side badge calculation or it may confuse some users . Note that we do NOT need to validate these URLs because the BadgeApp 1 . escapes these ( as part of normal processing ) against XSS attacks and 2 . does not traverse these URLs in its automated processing . Thus this rule is intentionally * not * strict at all . Contrast this with the intentionally strict validation of the project and repo URLs which * are * traversed by BadgeApp and thus need to be much more strict .
def contains_url?(text)
    return false if !text || text.start_with?('// ')
    text =~ %r{https?://[^ ]{5}}
  end
def contains_url? ( text ) return false if ! text || text . start_with? ( '// ' ) text =~ %r{ https?://[^ ]{5} } end
Does this contain a URL *anywhere* in the (justification) text?
Does this contain a URL * anywhere * in the ( justification ) text?
text
<not_specific>