lib/onebox/engine/github_commit_onebox.rb in onebox-1.8.12 vs lib/onebox/engine/github_commit_onebox.rb in onebox-1.8.13
- old
+ new
@@ -3,20 +3,26 @@
class GithubCommitOnebox
include Engine
include LayoutSupport
include JSON
- matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
+ matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commits?/")
always_https
def url
"https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/commits/#{match[:sha]}"
end
private
def match
- @match ||= @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commit/(?<sha>[^/]+)})
+ return @match if @match
+
+ @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commits?/(?<sha>[^/]+)})
+
+ @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commits?/(?<sha>[^/]+)}) if @match.nil?
+
+ @match
end
def data
result = raw.clone
result['link'] = link