   "Evaluates to a match form, used by the make-app function."
   [{:keys [host-regex context-path]} uri-sym server-name-sym]
   (let [host-test `(re-matches ~host-regex ~server-name-sym)
-        context-test `(.startsWith ~uri-sym ~context-path)]
+        context-test `(and (.startsWith ~uri-sym ~context-path)
+                           (= (get ~uri-sym ~(count context-path)) \/))]
     `(and ~@(remove nil? (list (when host-regex host-test)
                                (when context-path context-test))))))
 

                                         ~'server-name (:server-name ~'request)]
                                     (or ~@(for [app sorted]
                                             `(when (matcher ~(:ring-conf app) ~'uri ~'server-name)
                                                (boxure/call-in-box ~(:box app)
                                                                    ~(:handler-fn app)
                                                                    ~'request))))))]
                    (eval fn-form))
                  (constantly {:status 503 :body "no apps loaded"}))]
    (alter-var-root #'app (constantly handler))))

(defn- clean-ring-conf
  "Updates the ring-conf, in order to ensure some properties of the values."
  [ring-conf]
  (let [result ring-conf
        result (update-in result [:context-path]
                          #(when % (if (= (last %) \/) (apply str (butlast %)) %)))
        result (update-in result [:context-path]
                          #(when % (if (= (first %) \/) % (str "/" %))))]
    result))


(defn upstart-box
