
Strumento di sicurezza per tracciare i salti degli URL attraverso i link rel per ottenere l'ultimo URL
Hoper mostra ogni hop (redirect) che un URL attraversa fino a raggiungere la sua destinazione finale — utile per accorciatori di URL, link di tracciamento nelle email, flussi SSO o per il debug delle regole di redirect.
$ hoper http://github.com
Tracing http://github.com
1. → 301 Moved Permanently http://github.com/ 81ms
2. ✔ 200 OK https://github.com/ 50ms
1 redirect → https://github.com/
HEAD per impostazione predefinita (nessun download del corpo) con fallback automatico a GET per i server che lo rifiutano.HTTP_PROXY / HTTPS_PROXY / NO_PROXY e NO_COLOR.Richiede Ruby 3.1 o versione successiva.
gem install hoper
Su Windows, installa Ruby con RubyInstaller e poi esegui lo stesso comando.
hoper [options] URL [URL...]
-m, --max-hops N Maximum redirects to follow (default: 20)
-t, --timeout SECONDS Timeout per request (default: 10)
-X, --method METHOD HTTP method: HEAD or GET (default: HEAD)
-A, --user-agent UA User-Agent header to send
-H, --header 'NAME: VALUE' Extra request header (repeatable)
-k, --insecure Do not verify TLS certificates
-j, --json Output results as JSON
--[no-]color Force/disable colored output
-v, --version Print version and exit
-h, --help Show this help
Se lo schema viene omesso, si assume https:// (hoper example.com).
hoper --json http://github.com
{
"start_url": "http://github.com/",
"final_url": "https://github.com/",
"final_status": 200,
"redirects": 1,
"hops": [
{ "url": "http://github.com/", "status": 301, "reason": "Moved Permanently", "location": "https://github.com/", "duration_ms": 81 },
{ "url": "https://github.com/", "status": 200, "reason": "OK", "duration_ms": 50 }
]
}
Con più URL l'output è un array.
| Codice | Significato |
|---|---|
| 0 | Ogni URL è stato risolto in una risposta finale non di errore (< 400) |
| 1 | Almeno un URL ha fallito (errore di rete, loop, troppi salti, 4xx/5xx) |
| 2 | Utilizzo / opzioni non validi |
require "hoper"
result = Hoper.trace("https://bit.ly/example", max_hops: 10)
result.hops.each { |hop| puts "#{hop.status} #{hop.url}" }
result.final_url # => "https://example.com/"
result.success? # => true
bundle install
bundle exec rake test
CI esegue la suite di test su Ubuntu, macOS e Windows (Ruby 4.0), oltre alla versione più vecchia di Ruby supportata (3.1) su Ubuntu. I test utilizzano un server HTTP locale in-process, quindi non necessitano di accesso alla rete.
I rilasci sono automatizzati con GitHub Actions e RubyGems Trusted Publishing:
Incrementa lib/hoper/version.rb e aggiungi una sezione a CHANGELOG.md; esegui il merge su master.
Crea il tag e fai il push:
git tag v1.2.3 && git push origin v1.2.3
Il workflow Release verifica che il tag corrisponda alla versione, esegue i test, pubblica la gem su RubyGems.org e crea una GitHub Release con le note del CHANGELOG.
Segnalazioni di bug e pull request sono benvenute su GitHub all'indirizzo https://github.com/gabamnml/hoper. Questo progetto intende essere uno spazio sicuro e accogliente per la collaborazione, e ci si aspetta che i contributori rispettino il codice di condotta Contributor Covenant.
La gem è disponibile come open source secondo i termini della MIT License.