Skip to content

Commit

Permalink
Preferences: Fix handling of modified source code URL(#4437)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SamantazFox committed Jul 21, 2024
2 parents 5a12005 + 499aed3 commit 8b1da20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/invidious/routes/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/views/user/preferences.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

Expand Down

0 comments on commit 8b1da20

Please sign in to comment.