Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim the value in case it contains newlines #2480

Merged
merged 2 commits into from
Nov 30, 2022
Merged

Conversation

spapas
Copy link
Contributor

@spapas spapas commented Nov 30, 2022

Changes

Hello friends, I'm trying to self-host plausible on my server and have observed that if I add a file named (for example) secrets/LISTEN_IP to configure the bind IP I'll get the following error:

Compiling 1 file (.ex)
** (RuntimeError) Invalid LISTEN_IP '172.19.130.83
' error: :einval
    /home/serafeim/plausible/config/runtime.exs:20: (file)

(notice that I get the same error when configuring the DATABASE_URL or whatever comes first)

It seems that for whatever reason the File.read! will insert a newline at the end of the file. Notice that I have double checked the file with vim and it does not contain a newline at the end or at least I don't know how to make the file not have a newline at the end.

Thus I'm adding a String.trim() there to fix that thing; even if I am doing something wrong and my files do contain a newline at the end, adding a String.trim() there definite won't hurt :)

Below you'll find a checklist. For each item on the list, check one option and delete the other.

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

Copy link
Contributor

@ukutaht ukutaht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @spapas! Good addition ❤️ Files do often contain newlines at the end as well so it makes sense to trim these.

Could you also please add a note to the changelog under FIXED?

@spapas
Copy link
Contributor Author

spapas commented Nov 30, 2022

Done, thank you!

@bundlemon
Copy link

bundlemon bot commented Nov 30, 2022

BundleMon

Unchanged files (7)
Status Path Size Limits
static/css/app.css
515.19KB -
static/js/dashboard.js
297.98KB -
static/js/app.js
12.13KB -
static/js/embed.host.js
5.58KB -
static/js/embed.content.js
5.06KB -
tracker/js/plausible.js
748B -
static/js/applyTheme.js
314B -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@vinibrsl vinibrsl merged commit fd6ebf7 into plausible:master Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants