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(getRootUrl)!: If not configured use first subdirectory as webroot instead of last #570

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jan 29, 2024

Situation: Webserver configured for path rewrite (remove the index.php):

Before:

  • Current path: /nextcloud/apps/files
  • Result of getRoot(): /nextcloud/apps

After:

  • Current path: /nextcloud/apps/files
  • Result of getRoot(): /nextcloud

This affects only situations where the web root is not correctly configured by Nextcloud, but I think we should then only expect the first sub-directory to be the web root instead of all directories.

… instead of last

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux added bug Something isn't working 3. to review labels Jan 29, 2024
Copy link

codecov bot commented Jan 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3f8327e) 97.53% compared to head (7a2109f) 98.75%.
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #570      +/-   ##
==========================================
+ Coverage   97.53%   98.75%   +1.21%     
==========================================
  Files           1        1              
  Lines         243      240       -3     
  Branches       36       35       -1     
==========================================
  Hits          237      237              
+ Misses          5        1       -4     
- Partials        1        2       +1     

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

Copy link
Contributor

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

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

Changes make sense, but I've never tried a webroot configuration, so might miss something important

Copy link
Contributor

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

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

Gave it a test, as close as possible:

  • webroot is configured for docker-dev as per issue description: Document using a different webroot juliusknorr/nextcloud-docker-dev#297
  • couldn't set htaccess.RewriteBase in config
  • window._oc_webroot is set to undefined (NC resolves it automatically even if wasn't configured in config.php)
  • used webroot = webroot.replace('/index.php/', '/') (to imitate rewritebase)
Before After
image image

So far, previous code breaks all requests, which used getRootUrl, if app ever reach this line

@susnux susnux merged commit 49c9775 into master Jan 31, 2024
15 checks passed
@susnux susnux deleted the fix/webroot branch January 31, 2024 18:02
@Antreesy Antreesy mentioned this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants