Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upWhen returning index files, prefer .html and .htm files - fixes #48 #239
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
stig
Jan 6, 2016
Contributor
I tried to avoid having two first calls, but that function only accepts one argument and I didn't want to create an intermediate sequence in order to do so. This should be slightly faster than the old code, particularly for big directories, as it does not need to traverse the directory entry in the common(?) case of index.html or index.htm existing.
|
I tried to avoid having two |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
weavejester
Jan 6, 2016
Member
The function is getting a little large. Perhaps it would make more sense to split it up further. For example:
(defn- find-index-file [^File dir]
(or (existing-file (File. dir "index.html"))
(existing-file (File. dir "index.htm"))
(find-file-starting-with dir "index.")))|
The function is getting a little large. Perhaps it would make more sense to split it up further. For example: (defn- find-index-file [^File dir]
(or (existing-file (File. dir "index.html"))
(existing-file (File. dir "index.htm"))
(find-file-starting-with dir "index."))) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Sure, makes sense. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
stig
Jan 6, 2016
Contributor
How's this? I found I couldn't use find-file because it actually uses find-index-file internally.
|
How's this? I found I couldn't use |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
weavejester
Jan 6, 2016
Member
Just check whether the file exists. If it can't be read, it's better to let it throw an exception. So something more like:
(defn- existing-file [^File dir ^String name]
(let [file (File. dir name)]
(if (.exists file) file)))Also, I don't think the docstrings are necessary. Really, the other private function shouldn't have them either.
|
Just check whether the file exists. If it can't be read, it's better to let it throw an exception. So something more like: (defn- existing-file [^File dir ^String name]
(let [file (File. dir name)]
(if (.exists file) file)))Also, I don't think the docstrings are necessary. Really, the other private function shouldn't have them either. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
stig
Jan 6, 2016
Contributor
Thanks for the feedback! Want me to rebase the above into a single commit?
|
Thanks for the feedback! Want me to rebase the above into a single commit? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Yes please. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
weavejester
Jan 9, 2016
Member
Thanks for the commit. Could you change the commit message to:
Prefer HTML index files in file-response function
I think that more succinctly describes the gist of the change. I'll merge after that.
|
Thanks for the commit. Could you change the commit message to:
I think that more succinctly describes the gist of the change. I'll merge after that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Done. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Are you having second thoughts about merging this? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Nope, the notification email just slipped me by. |
stig commentedJan 6, 2016
After that, fall back to the old behaviour, which might end up returning
index.php, index.JS, index.GIF or anything else.