https://github.com/librariesio/librariesio-url-parser
Parse the URL for various repositories tracked by libraries.io
https://github.com/librariesio/librariesio-url-parser
Last synced: 12 months ago
JSON representation
Parse the URL for various repositories tracked by libraries.io
- Host: GitHub
- URL: https://github.com/librariesio/librariesio-url-parser
- Owner: librariesio
- License: agpl-3.0
- Created: 2022-06-10T20:27:35.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-16T01:32:39.000Z (over 1 year ago)
- Last Synced: 2025-06-02T10:01:35.486Z (about 1 year ago)
- Language: Ruby
- Size: 66.4 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Libraries.io URL Parser
Repository URL parsing library for https://libraries.io
## Usage
Parse a org/repo string from an input string:
```ruby
GithubURLParser.parse("https://github.com/rails/rails/") #=> rails/rails
GithubURLParser.parse("git@github.com: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:
```ruby
GithubURLParser.parse_to_full_url("https://github.com/rails/rails/") #=> https://github.com/rails/rails
GithubURLParser.parse_to_full_url("git@github.com: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:
```ruby
GithubURLParser.parse_to_full_user_url("https://github.com/rails/rails/") #=> nil
GithubURLParser.parse_to_full_user_url("git@github.com: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
```ruby
URLParser.try_all("git@github.com:rails/rails.git") #=> https://github.com/rails/rails
URLParser.try_all("git@gitlab.com:inkscape/inkscape.git") #=> "https://gitlab.com/inkscape/inkscape"
URLParser.try_all("git@bitbucket.org: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](http://contributor-covenant.org) code of conduct.