Don't escape the text of sauce links

also add a '?' link instead of crashing when the host name can't be identified
This commit is contained in:
ccd0 2014-05-12 21:56:25 -07:00
parent 57ed5e8055
commit 12b0bdb8b0

View File

@ -15,7 +15,11 @@ Sauce =
name: 'Sauce' name: 'Sauce'
cb: @node cb: @node
createSauceLink: (link, post, a) -> createSauceLink: (link, post, a) ->
link = link.replace /%(T?URL|MD5|board|name)/g, (parameter) -> text = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)?[1] or '?'
link = link.replace /;text:.+$/, ''
parts = [link, text]
for i in [0..1]
parts[i] = parts[i].replace /%(T?URL|MD5|board|name)/g, (parameter) ->
if type = { if type = {
'%TURL': post.file.thumbURL '%TURL': post.file.thumbURL
'%URL': post.file.URL '%URL': post.file.URL
@ -23,13 +27,11 @@ Sauce =
'%board': post.board '%board': post.board
'%name': post.file.name '%name': post.file.name
}[parameter] }[parameter]
encodeURIComponent(type) if i is 0 then encodeURIComponent(type) else type
else else
parameter parameter
text = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)[1] a.href = parts[0]
link = link.replace /;text:.+$/, '' a.textContent = parts[1]
a.href = link
a.textContent = text
a a
node: -> node: ->
return if @isClone or !@file return if @isClone or !@file