Skip to content

Commit

Permalink
Extended to support https and ftp
Browse files Browse the repository at this point in the history
  • Loading branch information
amaslenn committed Apr 11, 2013
1 parent 60fc463 commit a26c94c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _plugins/domain_name.filter.rb
Expand Up @@ -4,7 +4,7 @@ module DomainNameFilter

# Return the url's domain name
def domain_name(url)
return url.sub(%r{(http://){0,1}([^/]*)(/.*$){0,1}}i, '\\2')
return url.sub(%r{([a-z]+?://)?([^/]*)(/.*$)?}i, '\\2')
end

end
Expand Down
5 changes: 4 additions & 1 deletion test/test_domain_name.rb
Expand Up @@ -15,7 +15,10 @@ def test_domain_name
'http://example.com/reviews/index.php',
'example.com',
'example.com/reviews/',
'example.com/reviews/index.php']
'example.com/reviews/index.php',
'https://example.com',
'https://example.com/lvl/page.html',
'ftp://example.com']

urls.each do |url|
@context['var'] = url
Expand Down

0 comments on commit a26c94c

Please sign in to comment.