Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Our architecture didn't allow us
# to customize message body in a right way.
# That is why we fuck it up right here.
def fuck_short_url(text)
return nil unless text
# Offer short url in email should differ from generic one
# Additional parameters should be included:
# share_specific_short_url includes {source: 'email', email_shared_with: email}
# Sometimes we can not avoid this hack because of the following usecase:
# When user is sharing offer via email though talkable offer page
# Email body might have a link within.
# For example user sees the following message body:
# "I can get you $25 off with this link: http://www.talkable.com/x/Uk6EX"
# In "Share this offer by email" form
# But this link doesn't yet know the email person wants to share with.
# And we are not able to set a placeholder
# That is why we need this hack to replace it.
whitelist = [site.url, site.custom_domain].compact
text.gsub(URI.regexp(['http', 'https'])) do |url|
whitelist.include?(url) ? url : self.share_specific_short_url
end
end

Typo: though -> through

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment