racket/collects/syntax/private/modhelp.rkt
Matthew Flatt facc8db712 change module-path?' to subsume path?'
Although th eoriginal idea was to distinguish "text" paths
from derived filesystem paths, practically everythign that accepts
a module path also accepts a path. Building the generalization into
`module-path?' makes it easier to support `submod' wrappers on paths,
and it seems to fix things rather than break them.
2012-03-12 21:08:54 -06:00

16 lines
462 B
Racket

#lang racket/base
(provide explode-relpath-string
module-path-v-string?)
(define (explode-relpath-string p)
(map (lambda (p)
(cond [(assoc p '((#"." . same) (#".." . up))) => cdr]
[else (bytes->path p)]))
(regexp-split #rx#"/+" (string->bytes/utf-8 p))))
(define (module-path-v-string? v)
(and (regexp-match? #rx"^[-a-zA-Z0-9./]+$" v)
(not (regexp-match? #rx"^/" v))
(not (regexp-match? #rx"/$" v))))