merge fix
Some checks failed
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Test the built package works basically. (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been cancelled
ChangeDetection.io App Test / lint-code (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-10 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-11 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-12 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-13 (push) Has been cancelled

This commit is contained in:
dgtlmoon
2025-10-31 16:02:51 +01:00
parent 843659d9e9
commit 76c6a602fa
2 changed files with 7 additions and 18 deletions

View File

@@ -12,6 +12,9 @@ import copy
# Import schemas from __init__.py
from . import schema, schema_create_watch, schema_update_watch, validate_openapi_request
from ..notification import valid_notification_formats
from ..notification.handler import newline_re
def validate_time_between_check_required(json_data):
"""
@@ -221,9 +224,8 @@ class WatchHistoryDiff(Resource):
output_format = request.args.get('format', 'text').lower()
# Validate format
valid_formats = ['text', 'html', 'htmlcolor']
if output_format not in valid_formats:
abort(400, message=f"Invalid format. Must be one of: {', '.join(valid_formats)}")
if output_format not in valid_notification_formats.keys():
abort(400, message=f"Invalid format. Must be one of: {', '.join(valid_notification_formats.keys())}")
# Get the word_diff parameter (default to False - line-level mode)
word_diff = strtobool(request.args.get('word_diff', 'false'))
@@ -270,21 +272,9 @@ class WatchHistoryDiff(Resource):
)
mimetype = "text/html" if output_format == 'html' else "text/plain"
import re
if 'html' in output_format:
content = re.sub(
r'\r?\n?',
'<br>\\r\\n',
content
)
else:
# texty types
content = re.sub(
r'\r?\n?',
'\\r\\n',
content
)
content = newline_re.sub('<br>\r\n', content)
response = make_response(content, 200)
response.mimetype = mimetype
return response