Skip to content

Commit

Permalink
Detect custom domains in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
bfontaine committed Jun 18, 2016
1 parent 0211032 commit 15e1233
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/badges2svg.rb
Expand Up @@ -23,21 +23,16 @@ class << self
# - +:string+ the URL replacement. The protocol shouldn't be specified. If
# you wish to use the +shields.io+ start your replacement with a slash
# (+/+).
# - +:domain+ (optional): if you specified a custom domain in the +:string+
# key, set this one to +true+ to tell +BadgesToSVG+ not to prepend the
# default domain.
RULES = [
{ :name => :travis_branch,
:pattern => 'https?://(?:secure.)?travis-ci.org/%{user}/%{repo}.png' +
'\\?branch=%{branch}',
:string => 'travis-ci.org/%{user}/%{repo}.svg?branch=%{branch}',
:domain => true
},
{
:name => :travis,
:pattern => 'https?://(?:secure.)?travis-ci.org/%{user}/%{repo}.png',
:string => 'travis-ci.org/%{user}/%{repo}.svg',
:domain => true
},
{
:name => :gratipay,
Expand All @@ -59,7 +54,6 @@ class << self
:name => :gemnasium,
:pattern => 'https?://gemnasium.com/%{user}/%{repo}.png',
:string => 'gemnasium.com/%{user}/%{repo}.svg',
:domain => true
},
{
:name => :code_climate,
Expand Down Expand Up @@ -101,7 +95,6 @@ class << self
:name => :inch_ci,
:pattern => 'https?://inch-ci.org/github/%{user}/%{repo}.png\\?branch=%{branch}',
:string => 'inch-ci.org/github/%{user}/%{repo}.svg?branch=%{branch}',
:domain => true,
},
{
:name => :misc_png,
Expand Down Expand Up @@ -149,7 +142,7 @@ def compile_pattern(pattern)
def replace(content, opts={})
root = root_url(opts)
RULES.each do |r|
if r[:domain]
unless r[:string].start_with? "/"
rule_opts = {:protocol => r[:protocol], :domain => ''}
myroot = root_url({}.update(opts).update(rule_opts))
else
Expand Down

0 comments on commit 15e1233

Please sign in to comment.