uri.ss
#lang scheme

(require net/url-structs)
(require net/url)

(define (path-components uri)
  (map path/param-path (url-path uri)))

(define (extract-path uri)
  (struct-copy url uri (user #f) (host #f) (port #f) (scheme #f)))

(define (extension uri)
  (let ([match (regexp-match #rx"\\.([^\\.]+)" (last (path-components uri)))])
    (if match (cadr match)
        #f)))

(provide path-components extract-path extension)