Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to reject a post based on some attributes
# We are using the default ruby http client for the request to the
# shortened url, because otherwise a Gemfile or something different
# would be necessary
require 'net/http'
# I am using an example url from (with url shortener)
uri = URI('')
res = Net::HTTP.get_response(uri)
# Here you could also countercheck a blacklist array or something
# Just check for the domain name, because otherwise wds will change to https
if res.code === '301' && res.read_header['Location'].include?('') {
# Reject or do something different
} else {
# Accept the posting here posting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment