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

Extra forward slash in URLs when config["url"] has a trailing forward slash #6947

Open
4 of 17 tasks
inconvergent opened this issue Apr 22, 2018 · 4 comments
Open
4 of 17 tasks
Labels

Comments

@inconvergent
Copy link

  • [?] I believe this to be a bug, not a question about using Jekyll.
  • I updated to the latest Jekyll (or) if on GitHub Pages to the latest github-pages
  • I ran jekyll doctor to check my configuration
  • I read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
  • This is a feature request.

  • I am on (or have tested on) macOS 10+
  • I am on (or have tested on) Debian/Ubuntu GNU/Linux
  • I am on (or have tested on) Fedora GNU/Linux
  • I am on (or have tested on) Arch GNU/Linux
  • I am on (or have tested on) Other GNU/Linux
  • I am on (or have tested on) Windows 10+

  • I was trying to install.
  • There is a broken Plugin API.
  • I had an error on GitHub Pages, and I have reproduced it locally.
  • I had an error on GitHub Pages, and GitHub Support said it was a Jekyll Bug.
  • I had an error on GitHub Pages and I did not test it locally.
  • I was trying to build.
  • It was another bug.

My Reproduction Steps

I am opening this at the request of @pathawks (jekyll/jekyll-redirect-from#178 (comment)). It was initially posted here
jekyll/jekyll-redirect-from#178 (comment)

The issue relates to redirects (using the redirect-from plugin) on github pages vs. my local setup.

I've tested this on the same version of jekyll (3.7.3) and jekyll-redirect-from (0.13.0) as what is listed as current on github: https://pages.github.com/versions/

When using the redirect plugin i get // between the domain name and the path.

When I'm using redirect_from on my jekyll page it works as expected locally. but on on the github page there is an extra slash.

As an example.

i redirect like this: redirect_from: /summary/2017/

I don't know it is relevant, but my baseurl is "" (empty string).

When i curl the two different pages i get the following:

  curl -v  'http://localhost:4000/summary/2017/' 
*   Trying ::1...
* connect to ::1 port 4000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4000 (#0)
> GET /summary/2017/ HTTP/1.1
> Host: localhost:4000
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK 
< Etag: 6a06d9-1e5-5adc78be
< Content-Type: text/html; charset=utf-8
< Content-Length: 485
< Last-Modified: Sun, 22 Apr 2018 11:57:50 GMT
< Cache-Control: private, max-age=0, proxy-revalidate, no-store, no-cache, must-revalidate
< Server: WEBrick/1.3.1 (Ruby/2.3.1/2016-04-26)
< Date: Sun, 22 Apr 2018 11:59:25 GMT
< Connection: Keep-Alive
< 
<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting&hellip;</title>
  <link rel="canonical" href="http://localhost:4000/2017/summary/">
  <meta http-equiv="refresh" content="0; url=http://localhost:4000/2017/summary/">
  <meta name="robots" content="noindex">
  <h1>Redirecting&hellip;</h1>
  <a href="http://localhost:4000/2017/summary/">Click here if you are not redirected.</a>
  <script>location="http://localhost:4000/2017/summary/"</script>
</html>

And on the github page:

curl -v  'http://inconvergent.net/summary/2017/' 
*   Trying 192.30.252.153...
* Connected to inconvergent.net (192.30.252.153) port 80 (#0)
> GET /summary/2017/ HTTP/1.1
> Host: inconvergent.net
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: GitHub.com
< Date: Sun, 22 Apr 2018 11:59:43 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 497
< Vary: Accept-Encoding
< Last-Modified: Sun, 22 Apr 2018 11:57:08 GMT
< Vary: Accept-Encoding
< Access-Control-Allow-Origin: *
< Expires: Sun, 22 Apr 2018 12:09:43 GMT
< Cache-Control: max-age=600
< Accept-Ranges: bytes
< X-GitHub-Request-Id: 8304:04FC:2328C6A:3000660:5ADC792F
< 
<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting&hellip;</title>
  <link rel="canonical" href="http://inconvergent.net//2017/summary/">
  <meta http-equiv="refresh" content="0; url=http://inconvergent.net//2017/summary/">
  <meta name="robots" content="noindex">
  <h1>Redirecting&hellip;</h1>
  <a href="http://inconvergent.net//2017/summary/">Click here if you are not redirected.</a>
  <script>location="http://inconvergent.net//2017/summary/"</script>
</html>

The difference is in the <script> tag, and in the canonical link. As you will see there is a // between my domain and the url path.

solution

I found that this works as expected when i changed url: http://inconvergent.net/ to url: http://inconvergent.net in the config file.

@pathawks
Copy link
Member

It seems that site.url with a trailing slash breaks our URL filters.

We should remove any trailing slash before creating the URL.

@DirtyF
Copy link
Member

DirtyF commented Apr 22, 2018

@pathawks Shouldn't jekyll doctor warns about the trailing slash in site.url?

@pathawks
Copy link
Member

Maybe with Jekyll 4 we just do it automatically, and ensure baseurl is correct, when the config is loaded.

That way, we can avoid doing each time the filter is invoked.

@ashmaroli ashmaroli changed the title extra / when using redirect (custom domain, github page) Extra forward slash in URLs when config["url"] has a trailing forward slash May 2, 2018
@ashmaroli ashmaroli added the has-pull-request Somebody suggested a solution to fix this issue label May 8, 2018
@ashmaroli ashmaroli added help-wanted and removed has-pull-request Somebody suggested a solution to fix this issue labels Feb 18, 2019
@jekyllbot
Copy link
Contributor

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the latest 3.x-stable or master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider building it first as a plugin. Jekyll 3 introduced hooks which provide convenient access points throughout the Jekyll build pipeline whereby most needs can be fulfilled. If this is something that cannot be built as a plugin, then please provide more information about why in order to keep this issue open.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

@jekyllbot jekyllbot added the stale Nobody stepped up to work on this issue. label Apr 18, 2019
@jekyllbot jekyllbot added the has-pull-request Somebody suggested a solution to fix this issue label May 2, 2019
@mattr- mattr- added pinned and removed has-pull-request Somebody suggested a solution to fix this issue stale Nobody stepped up to work on this issue. labels Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants