From 31ddc71387fa9a95bff95992feb0f9e232ffb6e4 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 7 Dec 2005 01:43:19 +0000 Subject: [PATCH] open file URLs as html or text svn: r1548 --- collects/browser/private/hyper.ss | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/collects/browser/private/hyper.ss b/collects/browser/private/hyper.ss index 216072d436..7e57745c1c 100644 --- a/collects/browser/private/hyper.ss +++ b/collects/browser/private/hyper.ss @@ -325,9 +325,18 @@ A test case: (erase) (clear-undos) (let* ([mime-type (extract-field "content-type" mime-headers)] - [html? (and mime-type (regexp-match #rx"text/html" mime-type))] - [text? (and mime-type (regexp-match #rx"text/plain" mime-type))]) - + [path-extension (and (not mime-type) + (url? url) + (let ([p (url-path url)]) + (and (not (null? p)) + (regexp-match #rx"[.][^.]*$" + (car (last-pair p))))))] + [html? (or (and mime-type (regexp-match #rx"text/html" mime-type)) + (member path-extension '(".html" ".htm")))] + [text? (or (and mime-type (regexp-match #rx"text/plain" mime-type)) + (member path-extension '(".txt")) + (and (url? url) + (equal? (url-scheme url) "file")))]) (cond [(or (and mime-type (regexp-match #rx"application/" mime-type)) (and (url? url)