From 64638f67a7ceaaf07a3ec449a5667690189f9585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Wed, 13 Dec 2000 11:26:27 +0000 Subject: [PATCH] If the URL did not specify a scheme, try to guess it from the host name. --- usr.bin/fetch/fetch.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index c24d288659a4..024d71e806d4 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -197,6 +197,16 @@ fetch(char *URL, char *path) goto failure; } + /* if no scheme was specified, take a guess */ + if (!*url->scheme) { + if (!*url->host) + strcpy(url->scheme, SCHEME_FILE); + else if (strncasecmp(url->host, "ftp.", 4)) + strcpy(url->scheme, SCHEME_FTP); + else if (strncasecmp(url->host, "www.", 4)) + strcpy(url->scheme, SCHEME_HTTP); + } + timeout = 0; *flags = 0; count = 0;