Skip to content

DONE. :D#39

Open
abonner1 wants to merge 15 commits intopaircolumbus:masterfrom
abonner1:master
Open

DONE. :D#39
abonner1 wants to merge 15 commits intopaircolumbus:masterfrom
abonner1:master

Conversation

@abonner1
Copy link

@jaybobo

just letting you know. the secret page is a user's profile page.

private

def set_url
@url = Url.find_by(short_url: params[:short_url])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method is only invoked for one controller action, I'd suggest inlining it there.

@url.click_count += 1
@url.save

redirect_to "#{@url.long_url}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string interpolation isn't needed here. redirect_to @url.long_url should do the trick.

end

def url_params
params.require(:url).permit(:long_url, :short_url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We permit setting the short_url here, but there isn't an input in the form for it, and it will be overwritten in the model. I think short_url should be removed here.

def create_short_url
begin
short_url = SecureRandom.hex(4)
end while Url.where(short_url: short_url).exists?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure Url.exists?(short_url: short_url) works here too.


def compliant?
new_uri = URI.parse(self.long_url)
new_uri.is_a?(URI::HTTP) && !new_uri.host.nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you had a bug here. Instead, I just learned that URI::HTTPS is a subclass of URI::HTTP. 👍

@mikegee
Copy link
Member

mikegee commented May 16, 2018

I don't see an implementation for this URL validation yet:

  • Any URL-looking thing which responds to a HTTP request, i.e., we actually check to see if the URL is accessible via HTTP

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants