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

Path prefix not added when using the directory_indexes extension and http_prefix #1932

Open
murraysum opened this issue Jun 7, 2016 · 17 comments
Labels

Comments

@murraysum
Copy link

Issue

When using the set :http_prefix, "/deploy-test" configuration and the directory_indexes extension the path is not always prefixed when using the link_to helper.

If you use the link_to helper with the source file then it correctly prefixes the "/deploy-test" path:

# Correctly generates /deploy-test/test/
<%= link_to "This works", "/test.html", target: "_blank" %> 

However, if you use the link_to helper with a directory path then it doesn't prefix the "/deploy-test" path:

# Incorrectly generates /test/ instead of /deploy-test/test/
<%= link_to "This should work but does not work", "/test/", target: "_blank" %>

Expected Behaviour

I would expect that when linking to the directory path when using the directory_indexes extension would prefix /deploy-test

Actual Behaviour

Linking to the directory path when using the directory_indexes extension does not prefix /deploy-test

Reproducibility

I searched the documentation/previous issues and couldn't find anything related to this. Apologises if there has been. I've created a sample app on Middleman v4.1.9 at https://github.com/murraysum/deploy-test and it is deployed to http://murraysum.github.io/deploy-test/

Please let me know if you need any help reproducing. Thanks 👍

@tdreyno
Copy link
Member

tdreyno commented Jun 8, 2016

Great bug report. Thank you.

Does this work?

<%= link_to "This should work but does not work", "/test/index.html", target: "_blank" %>

@murraysum
Copy link
Author

@tdreyno Thanks for the prompt reply. 😀

As suggested I've tried the following and it does correctly prefix:

<%= link_to "This should work but does not work", "/test/index.html", target: "_blank" %>

I think linking to the directory feels cleaner. I am happy to put together a PR to add support to linking to directories with http_prefix if you would accept the patch. Thoughts?

@tdreyno
Copy link
Member

tdreyno commented Jun 8, 2016

Yeah, the URL rewriting code basically says "can I find this URL in the site, if so, modify". It'll never find the version without the index.html because that kind of directory -> file inference is outside of MM (usually Apache config).

There is an index_file config option. So if the URL we're looking for is possibly a directory (ends with / or has no extension), then attempt to look it up again with the / (if necessary) and index_file appended.

This should probably happen pretty deep in. In url_for or maybe Sitemap::Store.

There is also a strip_index_file config which should then try to remove the /index.html if it matches the resource, before outputting the string.

I'd love a PR. It's a bunch of somewhat conflicting extensions all trying to avoid stepping on each others' toes.

@abolishme
Copy link

Has this been resolved?

@murraysum
Copy link
Author

@abolishme Hello 👋. Unfortunately, it is still an issue on latest middleman (v4.1.12 as of writing). I didn't get a chance to look into creating a PR with a fix as I ended up not using github-pages so I didn't need to set a prefix path.

I've updated the sample app at https://github.com/murraysum/deploy-test to show it is still an issue in 4.1.12.

@noraj
Copy link

noraj commented Aug 9, 2020

Still an issue with 4.3.7, http_prefix not prefixing anything to link_to avoid from deploying to a subfolder.
As said earlier when dealing with i18n sometimes using absolute links is requires especially when using directory_indexes for pretty urls.

@stale
Copy link

stale bot commented Jul 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 17, 2021
@noraj
Copy link

noraj commented Jul 19, 2021

stale bots...

@stale stale bot removed the wontfix label Jul 19, 2021
@stale
Copy link

stale bot commented Sep 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 17, 2021
@noraj
Copy link

noraj commented Sep 17, 2021

unstale

@stale stale bot removed the wontfix label Sep 17, 2021
@stale
Copy link

stale bot commented Nov 16, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 16, 2021
@noraj
Copy link

noraj commented Nov 17, 2021

has this been fixed?

@stale stale bot removed the wontfix label Nov 17, 2021
@stale
Copy link

stale bot commented Jan 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 16, 2022
@noraj
Copy link

noraj commented Jan 17, 2022

unstale

@stale stale bot removed the wontfix label Jan 17, 2022
@stale
Copy link

stale bot commented Mar 18, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 18, 2022
@noraj
Copy link

noraj commented Mar 19, 2022

Still an issue with 4.3.7, http_prefix not prefixing anything to link_to avoid from deploying to a subfolder. As said earlier when dealing with i18n sometimes using absolute links is requires especially when using directory_indexes for pretty urls.

Any news?

@stale stale bot removed the wontfix label Mar 19, 2022
@stale
Copy link

stale bot commented Jun 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 17, 2022
@stale stale bot closed this as completed Jul 17, 2022
@tdreyno tdreyno removed the stale label Jul 18, 2022
@tdreyno tdreyno reopened this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants