https://github.com/gamache/fuzzyurl.rb
A Ruby Gem for non-strict parsing, manipulation, and wildcard matching of URLs.
https://github.com/gamache/fuzzyurl.rb
Last synced: about 7 hours ago
JSON representation
Repository metadata
A Ruby Gem for non-strict parsing, manipulation, and wildcard matching of URLs.
- Host: GitHub
- URL: https://github.com/gamache/fuzzyurl.rb
- Owner: gamache
- License: mit
- Created: 2015-12-26T18:50:56.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-30T16:28:24.000Z (over 8 years ago)
- Last Synced: 2025-12-05T11:18:31.895Z (7 days ago)
- Language: Ruby
- Homepage:
- Size: 351 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
README.md
Fuzzyurl
Non-strict parsing, composition, and wildcard matching of URLs in
Ruby.
Introduction
Fuzzyurl provides two related functions: non-strict parsing of URLs or
URL-like strings into their component pieces (protocol, username, password,
hostname, port, path, query, and fragment), and fuzzy matching of URLs
and URL patterns.
Specifically, URLs that look like this:
[protocol ://] [username [: password] @] [hostname] [: port] [/ path] [? query] [# fragment]
Fuzzyurls can be constructed using some or all of the above
fields, optionally replacing some or all of those fields with a *
wildcard if you wish to use the Fuzzyurl as a URL mask.
Installation
Put the following in your Gemfile:
gem 'fuzzyurl', '~> 0.9.0'
Parsing URLs
irb> Fuzzyurl.from_string("https://api.example.com/users/123?full=true")
#=> #<Fuzzyurl:0x007ff55b914f58 @protocol="https", @username=nil, @password=nil, @hostname="api.example.com", @port=nil, @path="/users/123", @query="full=true", @fragment=nil>
Constructing URLs
irb> f = Fuzzyurl.new(hostname: "example.com", protocol: "http", port: "8080")
irb> f.to_s
#=> "http://example.com:8080"
Matching URLs
Fuzzyurl supports wildcard matching:
*matches anything, includingnull.foo*matchesfoo,foobar,foo/bar, etc.*barmatchesbar,foobar,foo/bar, etc.
Path and hostname matching allows the use of a greedier wildcard ** in
addition to the naive wildcard *:
*.example.commatchesfilsrv-01.corp.example.combut notexample.com.**.example.commatchesfilsrv-01.corp.example.comandexample.com./some/path/*matches/some/path/foo/barand/some/path/
but not/some/path/some/path/**matches/some/path/foo/barand/some/path/
and/some/path
The Fuzzyurl.mask function aids in the creation of URL masks.
irb> Fuzzyurl.mask
#=> #<Fuzzyurl:0x007ff55b039578 @protocol="*", @username="*", @password="*", @hostname="*", @port="*", @path="*", @query="*", @fragment="*">
irb> Fuzzyurl.matches?(Fuzzyurl.mask, "http://example.com:8080/foo/bar")
#=> true
irb> mask = Fuzzyurl.mask(path: "/a/b/**")
irb> Fuzzyurl.matches?(mask, "https://example.com/a/b/")
#=> true
irb> Fuzzyurl.matches?(mask, "git+ssh://jen@example.com/a/b/")
#=> true
irb> Fuzzyurl.matches?(mask, "https://example.com/a/bar")
#=> false
Fuzzyurl.bestMatch, given a list of URL masks and a URL, will return
the given mask which most closely matches the URL:
irb> masks = ["/foo/*", "/foo/bar", Fuzzyurl.mask]
irb> Fuzzyurl.best_match(masks, "http://example.com/foo/bar")
#=> "/foo/bar"
If you'd prefer the array index instead of the matching mask itself, use
Fuzzyurl.best_match_index instead:
irb> Fuzzyurl.best_match_index(masks, "http://example.com/foo/bar")
#=> 1
Authorship and License
Fuzzyurl is copyright 2014-2015, Pete Gamache.
Fuzzyurl is released under the MIT License. See LICENSE.txt.
If you got this far, you should probably follow me on Twitter.
@gamache
Owner metadata
- Name: pete gamache
- Login: gamache
- Email:
- Kind: user
- Description: CTO and footgun architect at @appcues. API wonk and database curser.
- Website:
- Location: Lesser Boston, US in the A
- Twitter:
- Company: Appcues
- Icon url: https://avatars.githubusercontent.com/u/45100?u=f37d4b0a545b33056f3ef93fdcf28b85d016586c&v=4
- Repositories: 37
- Last ynced at: 2023-03-10T23:26:39.875Z
- Profile URL: https://github.com/gamache
GitHub Events
Total
Last Year
Committers metadata
Last synced: 7 days ago
Total Commits: 7
Total Committers: 1
Avg Commits per committer: 7.0
Development Distribution Score (DDS): 0.0
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| pete gamache | p****e@g****g | 7 |
Committer domains:
- gamache.org: 1
Issue and Pull Request metadata
Last synced: 3 months ago
Total issues: 1
Total pull requests: 2
Average time to close issues: N/A
Average time to close pull requests: 23 minutes
Total issue authors: 1
Total pull request authors: 2
Average comments per issue: 3.0
Average comments per pull request: 1.0
Merged pull request: 1
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- fuzzygroup (1)
Top Pull Request Authors
- gamache (1)
- stephengroat (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 3
-
Total downloads:
- rubygems: 100,947,421 total
- Total docker downloads: 923,334,026
- Total dependent packages: 6 (may contain duplicates)
- Total dependent repositories: 1,985 (may contain duplicates)
- Total versions: 13
- Total maintainers: 1
gem.coop: fuzzyurl
A library for non-strict parsing, construction, and wildcard-matching of URLs.
- Homepage: https://github.com/gamache/fuzzyurl.rb
- Documentation: http://www.rubydoc.info/gems/fuzzyurl/
- Licenses: MIT
- Latest release: 0.9.0 (published over 9 years ago)
- Last Synced: 2025-12-08T18:33:52.236Z (3 days ago)
- Versions: 6
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 50,478,563 Total
- Docker Downloads: 461,667,013
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.182%
- Docker downloads count: 0.235%
- Downloads: 0.495%
- Maintainers (1)
rubygems.org: fuzzyurl
A library for non-strict parsing, construction, and wildcard-matching of URLs.
- Homepage: https://github.com/gamache/fuzzyurl.rb
- Documentation: http://www.rubydoc.info/gems/fuzzyurl/
- Licenses: MIT
- Latest release: 0.9.0 (published over 9 years ago)
- Last Synced: 2025-12-07T18:02:24.503Z (4 days ago)
- Versions: 6
- Dependent Packages: 6
- Dependent Repositories: 1,985
- Downloads: 50,468,858 Total
- Docker Downloads: 461,667,013
-
Rankings:
- Docker downloads count: 0.291%
- Downloads: 0.538%
- Dependent repos count: 0.701%
- Dependent packages count: 2.828%
- Average: 6.755%
- Stargazers count: 14.037%
- Forks count: 22.136%
- Maintainers (1)
proxy.golang.org: github.com/gamache/fuzzyurl.rb
- Homepage:
- Documentation: https://pkg.go.dev/github.com/gamache/fuzzyurl.rb#section-documentation
- Licenses: mit
- Latest release: v0.8.0 (published almost 10 years ago)
- Last Synced: 2025-12-07T18:02:25.657Z (4 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 8.973%
- Average: 9.546%
- Dependent repos count: 10.118%
Dependencies
- coveralls >= 0 development
- minitest ~> 4.7.0 development
- mocha >= 0 development
- pry >= 0 development
- rake ~> 10.0 development
Score: 23.386316944780273