Open skalee opened 6 years ago
@skalee is this a case you think we should support?
Since user@server:project.git
is obviously not a URI, but a URI with the scheme
stripped away and the port replaced by a path, I think a good way to handle this using a special case.
validate :git_url, :uri_format -> { scheme: :git_short }
What do you think?
@ronaldtse I think that URI normalization is useful in general, not only in our URI format validator. One use case is uniqueness validation which should be performed with standard Rails validators on normalized URIs. This validation relies on performing a database query, hence normalized URI is required to be stored in a separate column.
Therefore, I think that URI normalization should be a separate feature, but I am not sure of details yet. Perhaps this feature should be moved to a separate gem? Perhaps uri_format_validator gem should be renamed to uri_field, and have both features? Neither I am sure how attribute normalization should be declared in user's code. Perhaps in a manner resembling attr_encrypted or attr_masker gem?
From Git Book:
That shorter scp-like is not a valid URI, even when prefixed with
ssh://
, because in URI a colon is expected to be followed with a port number. Both URI implementations in Ruby (stdlib's and Addressable's) are raising exception on parse attempt. However, this syntax is very popular, and perhaps dominant. For instance, GitHub features it in the "Clone or download" pop-up.