summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2024-07-21 14:02:20 +0200
committerSamantaz Fox <coding@samantaz.fr>2024-07-21 17:23:48 +0200
commit8b1da2001ea1ae7a8e86923c7ac0ec412979291d (patch)
treed39f08cfe3ca82477bc32fc7c4ac1b49571fc35a /src
parent5a12005b481367d9fbdf1f473abd84ce2bb6577b (diff)
parent499aed37dd4f6033cb35796c4c3a08dad65659be (diff)
downloadinvidious-8b1da2001ea1ae7a8e86923c7ac0ec412979291d.tar.gz
invidious-8b1da2001ea1ae7a8e86923c7ac0ec412979291d.tar.bz2
invidious-8b1da2001ea1ae7a8e86923c7ac0ec412979291d.zip
Preferences: Fix handling of modified source code URL(#4437)
Before this PR, setting the modified code repo URL through the preferences page in Invidious was broken: * the HTML input tag for this field had invalid type "input" (though browser falls back on text input) * the URL was used to set the "checked" property and not as a plain value, which makes no sense for a text-based input (and resulted in a blank field) * when the submitted field is empty, the retrieved value was an empty 'String' instead of 'nil', causing the "modified source code URL" to be an empty 'href' link which just pointed to the current page No associated open issue
Diffstat (limited to 'src')
-rw-r--r--src/invidious/routes/preferences.cr2
-rw-r--r--src/invidious/views/user/preferences.ecr2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr
index 112535bd..05bc2714 100644
--- a/src/invidious/routes/preferences.cr
+++ b/src/invidious/routes/preferences.cr
@@ -214,7 +214,7 @@ module Invidious::Routes::PreferencesRoute
statistics_enabled ||= "off"
CONFIG.statistics_enabled = statistics_enabled == "on"
- CONFIG.modified_source_code_url = env.params.body["modified_source_code_url"]?.try &.as(String)
+ CONFIG.modified_source_code_url = env.params.body["modified_source_code_url"]?.presence
File.write("config/config.yml", CONFIG.to_yaml)
end
diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr
index 55349c5a..b89c73ca 100644
--- a/src/invidious/views/user/preferences.ecr
+++ b/src/invidious/views/user/preferences.ecr
@@ -310,7 +310,7 @@
<div class="pure-control-group">
<label for="modified_source_code_url"><%= translate(locale, "adminprefs_modified_source_code_url_label") %></label>
- <input name="modified_source_code_url" id="modified_source_code_url" type="input" <% if CONFIG.modified_source_code_url %>checked<% end %>>
+ <input name="modified_source_code_url" id="modified_source_code_url" type="url" value="<%= CONFIG.modified_source_code_url %>">
</div>
<% end %>