From cddce5a02bebf4b377b737db8fb3e2311e40c9ad Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 9 Mar 2017 17:30:39 -0500 Subject: [PATCH] Avoid relative-path symlinks; see racket/racket issue #1563 --- examples/webchat/htdocs/syndicate.min.js | 1 - examples/webchat/htdocs/syndicatecompiler.min.js | 1 - examples/webchat/server/static-content.rkt | 14 ++++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) delete mode 120000 examples/webchat/htdocs/syndicate.min.js delete mode 120000 examples/webchat/htdocs/syndicatecompiler.min.js diff --git a/examples/webchat/htdocs/syndicate.min.js b/examples/webchat/htdocs/syndicate.min.js deleted file mode 120000 index 78aa5c5..0000000 --- a/examples/webchat/htdocs/syndicate.min.js +++ /dev/null @@ -1 +0,0 @@ -../../../js/dist/syndicate.min.js \ No newline at end of file diff --git a/examples/webchat/htdocs/syndicatecompiler.min.js b/examples/webchat/htdocs/syndicatecompiler.min.js deleted file mode 120000 index 4e22707..0000000 --- a/examples/webchat/htdocs/syndicatecompiler.min.js +++ /dev/null @@ -1 +0,0 @@ -../../../js/dist/syndicatecompiler.min.js \ No newline at end of file diff --git a/examples/webchat/server/static-content.rkt b/examples/webchat/server/static-content.rkt index 59245ef..97edc7e 100644 --- a/examples/webchat/server/static-content.rkt +++ b/examples/webchat/server/static-content.rkt @@ -15,15 +15,21 @@ (begin-for-declarations (define-runtime-path htdocs-path "../htdocs") (define-runtime-path templates-path "../htdocs/templates") + (define-runtime-path syndicate-js-dist-path "../../../js/dist") (define path->mime-type (make-path->mime-type "/etc/mime.types"))) (spawn #:name 'static-content-server (stop-when-reloaded) - (define url->path (make-url->path htdocs-path)) + (define static-paths (list htdocs-path syndicate-js-dist-path)) + (define url->path-fns (map make-url->path static-paths)) + (define (url->existing-static-path u) + (for/or [(url->path (in-list url->path-fns))] + (define-values (path path-pieces) (url->path u)) + (and (file-exists? path) path))) (on (web-request-get (id req) _ ,_) - (define-values (path path-pieces) - (url->path (resource->url (web-request-header-resource req)))) - (when (file-exists? path) + (define path (url->existing-static-path + (resource->url (web-request-header-resource req)))) + (when path (web-respond/bytes! id #:header (web-response-header #:mime-type (path->mime-type path)) (file->bytes path)))))