~soapdog/fafi-browser

cfbdab111b2f549878b6be5dda5868cdb35d2303 — Louis Brauer 3 years ago c6c8bd7
If entered url is w/o scheme, assume gemini://
2 files changed, 11 insertions(+), 5 deletions(-)

M utils.rkt
M window.rkt
M utils.rkt => utils.rkt +8 -1
@@ 39,6 39,13 @@
  (define (unescape-amp content)
    (string-replace content "&" "&"))
  (define (unescape-chars content)
    (string-replace (string-replace (string-replace content "&#60;" "<") "&#62;" ">") "&#34;" "'")) 
    (string-replace (string-replace (string-replace content "&#60;" "<") "&#62;" ">") "&#34;" "'"))
  (unescape-amp (unescape-gt (unescape-lt (unescape-chars content)))))

;; If the url doesn't contains a scheme, use gemini://
;; should add a test here
(define (ensure-scheme current-url)
  (define current-url-url (string->url current-url))
  (if (url-scheme (string->url current-url))
    current-url
    (string-append "gemini://" current-url)))

M window.rkt => window.rkt +3 -4
@@ 94,10 94,9 @@

(define (go-to-url [url #f])
  (when (false? url)
    (set! url (send address-bar get-value)))

  (set! history-backward (cons url history-backward))
  (send multi-transport fetch url))
    (let ([url (ensure-scheme (send address-bar get-value))])
      (set! history-backward (cons url history-backward))
      (send multi-transport fetch url))))

(define (go-forward)
  (when (> (length history-forward) 0)