Skip to content

Commit 6ea01cf

Browse files
committed
cleaned up fetch_raw_code method
1 parent 748c701 commit 6ea01cf

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/jekyll-gist/gist_tag.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ def gist_noscript_tag(gist_id, filename = nil)
5959
end
6060

6161
def fetch_raw_code(gist_id, filename = nil)
62-
if filename.empty?
63-
uri = "https://gist.githubusercontent.com/#{gist_id}/raw"
64-
else
65-
uri = "https://gist.githubusercontent.com/#{gist_id}/raw/#{filename}"
66-
end
6762
begin
68-
open(uri).read.chomp
63+
url = "https://gist.githubusercontent.com/#{gist_id}/raw"
64+
url = "#{url}/#{filename}" unless filename.empty?
65+
open(url).read.chomp
6966
rescue SocketError
7067
nil
7168
rescue OpenURI::HTTPError

0 commit comments

Comments
 (0)