]> git.cworth.org Git - turbot-web/commit
Abstract out the filename_from_name function
authorCarl Worth <cworth@cworth.org>
Wed, 12 Jan 2022 08:20:40 +0000 (00:20 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 12 Jan 2022 08:39:47 +0000 (00:39 -0800)
commitd443dffc599f0f858068bd22dcf289fcbe4d64f3
tree30100aa31abf6b9b754175ef5ddc8f212a4f97b7
parent88cc255b97357ff671194816186c88b6b42eaccf
Abstract out the filename_from_name function

Previously, there were many, many places i nthe code performing a
calculation of:

"_".join(name.split())

in order to replace all spaces with underscores before using a name as
a filename.

But as we determined recently, this is insufficient as we at least
need to also replaces all '/' with an '_' as well (to ensure that the
filename looks like a filename and not a directory plus a filename).

The previous fix for the '/' in one place, (immediately before writing
the file), meant that all the other places that were emitting links to
that file were now wrong.

We can ensure everything is consistent by having a single function for
all instances of this filename generation which we do here with the
new filename_from_name() function.
html_generator.py