                    client-secret
                    signing-secret]} (get-github-settings context)
            {:keys [code state]} (:query-params request)
-           web-client-redirect (remove-slash (get-in request [:headers "referer"]))
+           web-client-redirect (get-formatted-referer request)
            failed-callback (redirect-home context web-client-redirect)]
 
        (if (= state signing-secret)

                       "Accept" "application/json"}}))

(defn- remove-slash
  "Removes the trailing slash from a url (if it exists)"
  [url]
  (if (.endsWith url "/")
    (.substring url 0 (- (count url) 1))
    url))

(defn- parse-user-response
  "Parses the body if the request succeeded"

(ns wombats.handlers.auth
  (:require [clojure.string :refer [ends-with? join split]]
            [io.pedestal.interceptor.helpers :as interceptor]
            [org.httpkit.client :as http]
            [cheshire.core :refer [parse-string]]
            [wombats.interceptors.github :refer [get-github-settings]]
