Some endpoints are causing errors in Flask-Minify
Axedyson opened this issue · 1 comments
This is my setup:
minify(app=app, bypass=[r'users\.register', r'users\.contact'])
If I don't supply an argument to the bypass parameter no errors appear.
When I hit ctrl + u
Chrome takes me to the source code of a specific page.
For example I'm currently on the home page (http://127.0.0.1:5000/home)
Now I press ctrl + u
and it takes me to the source code of the home page
(view-source:http://127.0.0.1:5000/home)
When I do that I'm receiving the following errors:
Traceback (most recent call last): File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\_compat.py", line 39, in reraise raise value File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request return self.finalize_request(rv) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 1969, in finalize_request response = self.process_response(response) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask\app.py", line 2266, in process_response response = handler(response) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask_minify\main.py", line 151, in main should_bypass = self.get_endpoint_matches(self.bypass) File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask_minify\main.py", line 117, in get_endpoint_matches [compile_re(pattern) for pattern in patterns] File "c:\users\anders\onedrive\computer science\python\projekter\anime-website\env\lib\site-packages\flask_minify\main.py", line 118, in <listcomp> if compiled_pattern.match(self.endpoint)] TypeError: expected string or bytes-like object
Inside the get_endpoint_matches method (def get_endpoint_matches(self, patterns
)
self.endpoint
returns None
when the URL is: view-source:http://127.0.0.1:5000/blabla...
The method should probably just ignore endpoints that are None
, and that is exactly my current workaround for now.
original:
matches = [compiled_pattern for compiled_pattern in
[compile_re(pattern) for pattern in patterns]
if compiled_pattern.match(self.endpoint)]
workaround:
matches = [compiled_pattern for compiled_pattern in
[compile_re(pattern) for pattern in patterns]
if compiled_pattern.match(self.endpoint)] if self.endpoint else []
I think that endpoints for static files are not being handled properly by Flask-Minify.