fix 'static_url_path' defaulting for empty paths #3124
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
the documentation of the application object specifies static parameters:
static_url_path – can be used to specify a different path for the static
files on the web. Defaults to the name of the static_folder folder.
static_folder – the folder with static files that should be served at
static_url_path. Defaults to the 'static' folder in the root path of the
application.
so by my understanding,
app=Flask(__name__, static_folder='')
should allow for arbitrary (absolute) path structure for all static
files. it doesn't. but the following does:
app=Flask(__name__, static_folder='', static_url_path='')
given the above doc strings, that appears inconsistent
for this specific case (
static_folder=''
), stepping through thecodebase yielded:
<Rule '//' (GET, OPTIONS, HEAD) -> static>
re.compile('^\\|//(?P<filename>[^/].*?)$')
which is an expression that can never be satisfied by a valid url
please consider this trivial patch. i hope the tests are appropriate
too, it was difficult to know how much of the mechanism to incorporate
for such a small change
commit message:
-prefix a path delimiter iff there's a path to delimit
-ensures a valid default static route rule is created on application
intialisation for the case 'static_folder=""' and implicit
'static_url_path'
todo