arturo-lang / arturo

Simple, expressive & portable programming language for efficient scripting
http://arturo-lang.io
MIT License
695 stars 31 forks source link

[Helpers/url] verify `isUrl` is working right & testing for valid URLs #610

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

[Helpers/url] verify isUrl is working right & testing for valid URLs

Currently, our isUrl works with a RegEx - which looks pretty shady. If there's a better and more standards-compliant way to do it, we should - since lot's of things are based on this one.

https://github.com/arturo-lang/arturo/blob/ce734e7a32c73173910cdf8f533f56be21febe3b/src/helpers/url.nim#L23

#=======================================

# TODO(Helpers/url) verify `isUrl` is working right & testing for valid URLs
#  Currently, our `isUrl` works with a RegEx - which looks pretty shady. If there's a better and more standards-compliant way to do it, we should - since lot's of things are based on this one.
#  labels: helpers, enhancement, open discussion

func isUrl*(s: string): bool {.inline.} =
    when not defined(WEB):

        return s.contains("localhost:") or s.match(re"^(?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$")
    else:
        return false
ndex 5b1fd686c..ac4170ff6 100644
++ b/src/helpers/xml.nim

902b5ae96e9b3638aa0b0de8504e32a8c937217d

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

Closing issue as stale.

stale[bot] commented 9 months ago

Closing issue as stale.

stale[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.