remove uri-parser PARSE-URI
(completely out-of-date, has never seen RFC 2396)
This commit is contained in:
parent
649f374e8b
commit
2cb8502f9e
|
@ -14,40 +14,6 @@
|
|||
;;; - http://www.w3.org/hypertext/WWW/Addressing/URL/URI_Overview.html
|
||||
;;; General Web page of URI pointers.
|
||||
|
||||
(define uri-reserved (string->char-set ";/#?: ="))
|
||||
|
||||
(define uri-reserved-sans-= (char-set-delete uri-reserved #\=))
|
||||
|
||||
;;; Note: this "uri-parser" has never been adapted to RCF 2396
|
||||
;;; (Uniform Resource Identifiers: Generic Syntax)
|
||||
;;; It is rather useless by now since it's hard to determine
|
||||
;;; exactly which subset of RFC 2396's URIs it works for
|
||||
;;;(plus the subset it works for is a rather arbitrary one).
|
||||
|
||||
(define (parse-uri s)
|
||||
(let* ((slen (string-length s))
|
||||
;; Search forwards for colon (or intervening reserved char).
|
||||
(rs1 (string-index s uri-reserved)) ; 1st reserved char
|
||||
(colon (and rs1 (char=? (string-ref s rs1) #\:) rs1))
|
||||
(path-start (if colon (+ colon 1) 0))
|
||||
|
||||
;; Search backwards for # (or intervening reserved char).
|
||||
(rs-last (string-index-right s uri-reserved))
|
||||
(sharp (and rs-last (char=? (string-ref s rs-last) #\#) rs-last))
|
||||
|
||||
;; Search backwards for ? (or intervening reserved char).
|
||||
;; (NB: #\= may be after #\? and before #\#)
|
||||
(rs-penult (string-index-right s
|
||||
uri-reserved-sans-=
|
||||
path-start
|
||||
(or sharp slen)))
|
||||
(ques (and rs-penult (char=? (string-ref s rs-penult) #\?) rs-penult))
|
||||
|
||||
(path-end (or ques sharp slen)))
|
||||
(values (and colon (substring s 0 colon))
|
||||
(split-uri s path-start path-end)
|
||||
(and ques (substring s (+ ques 1) (or sharp slen)))
|
||||
(and sharp (substring s (+ sharp 1) slen)))))
|
||||
|
||||
;;; Caution:
|
||||
;;; Don't use this proc until *after* you've parsed the URL -- unescaping
|
||||
|
|
Loading…
Reference in New Issue