Skip to content

Conversation

@drpentode
Copy link

Removed custom URL regex and used standard regex provided by Ruby for more consistent URL matching. Test case included in test/scrivener_test.rb.

Choose a reason for hiding this comment

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

I did not know about this. Very cool!

@foca
Copy link
Contributor

foca commented May 4, 2016

bump

|localhost)(:[0-9]{1,5})?(\/.*)?\z/ix
URL = URI::regexp(%w(http https))

def assert_url(att, error = [att, :not_url])
Copy link
Contributor

Choose a reason for hiding this comment

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

Might make sense to pass the schemes here:

def assert_url(att, schemes = %w(http https), error = [att, :not_url])
  if assert_present(att, error)
    assert_format(att, URI.regexp(schemes), error)
  end
end

This would allow people to use this helper to check other kind of URLs without extra work. Thoughts?

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.

3 participants