Add hexadecimal MD5 to sauce search: %hMD5. #686

This commit is contained in:
ccd0 2016-01-11 14:44:48 -08:00
parent 4af720db33
commit fab72035c8
2 changed files with 3 additions and 1 deletions

View File

@ -10,6 +10,7 @@
<li><code>%IMG</code>: Full image URL for GIF, JPG, and PNG; thumbnail URL for other types.</li>
<li><code>%MD5</code>: MD5 hash in base64.</li>
<li><code>%sMD5</code>: MD5 hash in base64 using <code>-</code> and <code>_</code>.</li>
<li><code>%hMD5</code>: MD5 hash in hexadecimal.</li>
<li><code>%name</code>: Original file name.</li>
<li><code>%board</code>: Current board.</li>
<li><code>%%</code>, <code>%semi</code>: Literal <code>%</code> and <code>;</code>.</li>

View File

@ -42,13 +42,14 @@ Sauce =
skip = false
for key of parts
parts[key] = parts[key].replace /%(T?URL|IMG|s?MD5|board|name|%|semi)/g, (parameter) ->
parts[key] = parts[key].replace /%(T?URL|IMG|[sh]?MD5|board|name|%|semi)/g, (parameter) ->
type = {
'%TURL': post.file.thumbURL
'%URL': post.file.url
'%IMG': if ext in ['gif', 'jpg', 'png'] then post.file.url else post.file.thumbURL
'%MD5': post.file.MD5
'%sMD5': post.file.MD5?.replace /[+/=]/g, (c) -> {'+': '-', '/': '_', '=': ''}[c]
'%hMD5': if post.file.MD5 then ("0#{c.charCodeAt(0).toString(16)}"[-2..] for c in atob post.file.MD5).join('')
'%board': post.board.ID
'%name': post.file.name
'%%': '%'