Skip to content

Parse the URL for various repositories tracked by libraries.io

License

Notifications You must be signed in to change notification settings

librariesio/librariesio-url-parser

Repository files navigation

Libraries.io URL Parser

Repository URL parsing library for https://libraries.io

Usage

Parse a org/repo string from an input string:

GithubURLParser.parse("https://github.com/rails/rails/") #=> rails/rails
GithubURLParser.parse("[email protected]:rails/rails.git") #=> rails/rails
GithubURLParser.parse("https://github.com/rails/rails.git") #=> rails/rails
GithubURLParser.parse("https://github.com") #=> nil

Parse a full url from an input string:

GithubURLParser.parse_to_full_url("https://github.com/rails/rails/") #=> https://github.com/rails/rails
GithubURLParser.parse_to_full_url("[email protected]:rails/rails.git") #=> https://github.com/rails/rails
GithubURLParser.parse_to_full_url("https://github.com/rails/rails.git") #=> https://github.com/rails/rails
GithubURLParser.parse_to_full_url("https://github.com") #=> nil

Parse an org/user url from an input string:

GithubURLParser.parse_to_full_user_url("https://github.com/rails/rails/") #=> nil
GithubURLParser.parse_to_full_user_url("[email protected]:rails/rails.git") #=> nil
GithubURLParser.parse_to_full_user_url("https://github.com/rails/rails.git") #=> nil
GithubURLParser.parse_to_full_user_url("https://github.com") #=> nil
GithubURLParser.parse_to_full_user_url("https://github.com/rails") #=> https://github.com/rails

Parse a full url from an input string where the repository is unknown

URLParser.try_all("[email protected]:rails/rails.git") #=> https://github.com/rails/rails
URLParser.try_all("[email protected]:inkscape/inkscape.git") #=> "https://gitlab.com/inkscape/inkscape"
URLParser.try_all("[email protected]:tildeslash/monit.git") #=> "https://bitbucket.org/tildeslash/monit"

Supported repositories

  • GitHub
  • GitLab
  • Bitbucket
  • Apache SVN

Development

After checking out the repo, run bundle install to install dependencies. Then, run rake spec to run the tests.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/librariesio/librariesio-url-parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

About

Parse the URL for various repositories tracked by libraries.io

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages