secure-77 / Perlite

A web-based markdown viewer optimized for Obsidian
https://perlite.secure77.de/
MIT License
1.06k stars 92 forks source link

Reduce getenv calls, refactor checkArray readability #114

Closed selfiens closed 6 months ago

selfiens commented 8 months ago

While reading the code, I refactored the beginning part of the helper.php, mostly for readability. I found that the Docker uses PHP 8.2, and JavaScript uses ES6. My editions are based on these version constraint findings.

Changes are:

  1. Reduced the number of getenv calls by using new Env class, which wraps getenv to handle undefined keys better.
    • please note that initializers for $hideFolders, $allowedFileLinkTypes has been refactored, but maybe trim is needed to deal with redundant spaces.
  2. Refactored checkArray function.
  3. Updated some comments.