Improve GistTag (#555)
This commit is contained in:
parent
e7a0911b81
commit
b99566afb3
2 changed files with 5 additions and 2 deletions
|
|
@ -32,12 +32,14 @@ class GistTag < LiquidTagBase
|
|||
if valid_link?(link)
|
||||
input_no_space
|
||||
else
|
||||
raise StandardError, "Invalid Gist link"
|
||||
raise StandardError,
|
||||
"Invalid Gist link: #{link} Links must follow this format: https://gist.github.com/username/gist_id"
|
||||
end
|
||||
end
|
||||
|
||||
def valid_link?(link)
|
||||
(link =~ /^(http(s)?:)?\/\/(gist.github.com)\/.*/)&.zero?
|
||||
(link =~ /^https\:\/\/gist\.github\.com\/([a-zA-Z0-9\-]){1,39}\/([a-zA-Z0-9]){32}\s/)&.
|
||||
zero?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ RSpec.describe GistTag, type: :liquid_template do
|
|||
"//pastebin.com/raw/b77FrXUA#gist.github.com",
|
||||
"https://gist.github.com@evil.com",
|
||||
"https://gist.github.com.evil.com",
|
||||
"https://gist.github.com/string/string/raw/string/file",
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue