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

fix: loop over forward slashes for relative dir, replace after urlencode #64

Open
wants to merge 1 commit into
base: v5.5.x
Choose a base branch
from

Conversation

tiller1010
Copy link

@tiller1010 tiller1010 commented Jan 10, 2024

Fixes #63

  • Loops over forward slashes for "../" relative path.
  • Replaces URL-encoded forward slashes with the original slash.

Copy link
Member

@williamdes williamdes left a comment

Choose a reason for hiding this comment

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

This looks nice, I will check the code base to see if this is the right solution or if other places could be broken

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (78ee960) 63.99% compared to head (120ef45) 63.99%.

Additional details and impacted files
@@            Coverage Diff            @@
##             v5.5.x      #64   +/-   ##
=========================================
  Coverage     63.99%   63.99%           
  Complexity     1252     1252           
=========================================
  Files            53       53           
  Lines          3611     3611           
=========================================
  Hits           2311     2311           
  Misses         1300     1300           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@williamdes
Copy link
Member

Update: I am a bit unsatisfied about the current code, maybe I will refactor it a bit before merging this
We should not have to split the path and re build it, it feels wrong

@@ -69,7 +69,7 @@
<select class="form-control" id="version-switcher" name="version">
{% for version in project.versions %}
<option
value="{{ path('../' ~ version|url_encode ~ '/index.html') }}"
value="{% for i in project.version|split('/') %}../{% endfor %}{{ path(version|url_encode|replace({ '%2F': '/' }) ~ '/index.html') }}"
Copy link

@GuySartorelli GuySartorelli Mar 16, 2025

Choose a reason for hiding this comment

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

I'd recommend making a new template function in PHP-land.
That means:

  1. You can unit test the function
  2. Templates are easier to read - these templates are already pretty complicated
  3. If this same thing needs to happen elsewhere, the same function can be reused
  4. It's easier to make readable functional code in PHP than templates (imo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants