Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small changes to make jiggler easier to use and deploy #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Ensure base-url ends in /
  • Loading branch information
Leon Barrett committed Jan 28, 2018
commit 2612bcaefb35c9f99cd1e0962fba88455167df54
9 changes: 8 additions & 1 deletion src/jiggler/main.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
;; Copyright (c) 2017 Yieldbot
(ns jiggler.main
(:require
[clojure.string :as str]
[clojure.tools.cli :refer [parse-opts]]
[com.stuartsierra.component :as component]
[jiggler.db :as db]
[jiggler.routes :as routes])
(:gen-class))

(defn ensure-ends-in-slash [s]
(-> s
(str "/")
(str/replace #"/+$" "/")))

(def cli-options
[["-P" "--port PORT" "Port to serve HTTP"
:default 8666
@@ -28,7 +34,8 @@
:id :password
:default (System/getenv "PGPASSWORD")]
[nil "--base-url PATH" "The canonical URL to find this on the web"
:default "/"]
:default "/"
:parse-fn ensure-ends-in-slash]
[nil "--sqlite FILE" "Run with a SQLite database"]
[nil "--help"]])

5 changes: 5 additions & 0 deletions test/jiggler/main_test.clj
Original file line number Diff line number Diff line change
@@ -8,6 +8,11 @@
[jiggler.main :as main]
[jiggler.routes :as routes]))

(deftest test-ensure-ends-in-slash
(is (= "http://jiggler/a/" (main/ensure-ends-in-slash "http://jiggler/a")))
(is (= "http://jiggler/a/" (main/ensure-ends-in-slash "http://jiggler/a/")))
(is (= "http://jiggler/a/" (main/ensure-ends-in-slash "http://jiggler/a//"))))

(deftest test-errors
(binding [*out* (jio/writer "/dev/null")]
(with-redefs [main/exit! identity]