Changeset 13229 in project


Ignore:
Timestamp:
02/09/09 22:52:05 (11 years ago)
Author:
sjamaan
Message:

Rename old uri? predicate to uri-reference? and introduce a new uri? predicate that only returns #t when the object is an uri, not when it's a relative reference

Location:
release/4/uri-generic/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/uri-generic/trunk/tests/run.scm

    r13228 r13229  
    322322(test-group "absolute/relative distinction"
    323323  (for-each (lambda (s)
    324               (test-assert (sprintf "~S is relative" s)
     324              (test-assert (sprintf "~S is a relative ref" s)
    325325                           (relative-ref? (uri-reference s)))
    326               (test-assert (sprintf "~S is not absolute" s)
     326              (test-assert (sprintf "~S is not an URI" s)
     327                           (not (uri? (uri-reference s))))
     328              (test-assert (sprintf "~S is not an absolute URI" s)
    327329                           (not (absolute-uri? (uri-reference s))))
    328330              (test-error (absolute-uri s)))
    329331            relative-refs)
    330332  (for-each (lambda (s)
    331               (test-assert (sprintf "~S is not relative" s)
     333              (test-assert (sprintf "~S is not a relative ref" s)
    332334                           (not (relative-ref? (uri-reference s))))
    333               (test-assert (sprintf "~S is absolute" s)
     335              (test-assert (sprintf "~S is an URI" s)
     336                           (uri? (uri-reference s)))
     337              (test-assert (sprintf "~S is an absolute URI" s)
    334338                           (absolute-uri? (uri-reference s)))
    335339              (test (uri-reference s) (absolute-uri s)))
    336340            absolute-uris)
    337341  (for-each (lambda (s)
    338               (test-assert (sprintf "~S is not relative" s)
     342              (test-assert (sprintf "~S is not a relative ref" s)
    339343                           (not (relative-ref? (uri-reference s))))
    340               (test-assert (sprintf "~S is not absolute" s)
     344              (test-assert (sprintf "~S is an URI" s)
     345                           (uri? (uri-reference s)))
     346              (test-assert (sprintf "~S is not an absolute URI" s)
    341347                           (not (absolute-uri? (uri-reference s))))
    342348              ;; Should this give an error in the fragment case?
  • release/4/uri-generic/trunk/uri-generic.scm

    r13228 r13229  
    4242(module uri-generic
    4343  (uri-reference update-uri update-authority
    44    uri? uri-auth uri-authority uri-scheme uri-path uri-query
     44   uri-reference? uri-auth uri-authority uri-scheme uri-path uri-query
    4545   uri-fragment uri-host uri-port uri-username uri-password
    4646   authority? authority-host authority-port
    4747   authority-username authority-password
    4848   
    49    absolute-uri absolute-uri? uri->string uri->list
     49   uri? absolute-uri absolute-uri? uri->string uri->list
    5050   relative-ref? uri-relative-to uri-relative-from
    5151   uri-decode-string uri-encode-string
     
    8080           (URIAuth-port x)))
    8181
    82 (define uri? URI?)
     82(define uri-reference? URI?)
    8383
    8484(define uri-auth       URI-authority )
     
    281281;;               / path-empty
    282282
     283;; TODO: Export a modified version of this one, to match absolute-uri
     284;;       (modified = throw an error instead of #f)
    283285(define (uri s)
    284286  (let ((s (if (string? s) (uri-string->normalized-char-list s) s)))
     
    294296                                  fragment: (and uf (uri-char-list->string uf)))))
    295297         (else #f))))
     298
     299(define (uri? u)
     300  (and (uri-reference? u) (uri-scheme u)))
    296301
    297302(define (uri-path-list->path pcl)
     
    664669    (or (uri s) (relative-ref s))))
    665670
     671;; (define uri-reference? URI) ; Already defined as URI? (struct predicate)
     672
    666673;;  RFC3986, section 4.2
    667674;;
     
    673680;;                 / path-empty
    674681
     682;; TODO: Export a modified version of this  (one that accepts a string
     683;;       and throws an exception instead of returning #f)
    675684(define (relative-ref s)
    676685  (and (not (scheme s))
     
    685694
    686695(define (relative-ref? u)
    687   (and (uri? u) (not (uri-scheme u))))
     696  (and (uri-reference? u) (not (uri-scheme u))))
    688697
    689698(define (relative-part s)
     
    716725
    717726(define (absolute-uri? u)
    718   (and (uri? u) (not (relative-ref? u)) (not (uri-fragment u))))
     727  (and (uri-reference? u) (not (relative-ref? u)) (not (uri-fragment u))))
    719728
    720729;; Turns a URI into a string.
     
    825834
    826835(define (uri-relative-to ref base)
    827   (and (uri? ref) (uri? base)
     836  (and (uri-reference? ref) (uri-reference? base)
    828837       (cond ((uri-scheme ref)      (update-URI ref
    829838                                                path: (just-segments ref)))
Note: See TracChangeset for help on using the changeset viewer.