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

Add a Jekyll doctor warning for URLs that only differ by case #3171

Merged
merged 4 commits into from Dec 13, 2015

Conversation

akoeplinger
Copy link
Contributor

Those URLs are problematic on case-insensitive file systems because one of the URLs is overwritten by the other. Fixes #3035.

Note: I can't seem to find tests for doctor, I'm assuming there are none?

Those URLs are problematic on case-insensitive file systems because one of the URLs is overwritten by the other.
Fixes jekyll#3035
urls[dest.downcase] << dest
else
urls[dest.downcase] = [dest]
end
Copy link
Member

Choose a reason for hiding this comment

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

This if block can be simplified to:

(urls[dest.downcase] ||= []) << dest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but this would make it inconsistent with collect_urls() above. I'd say consistency is more important than short code? Or should I change the other method too?

Copy link
Member

Choose a reason for hiding this comment

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

Consistency is not important to me here. Theoretically every method should do entirely different things :)

@pathawks
Copy link
Member

Is there a way to detect whether the current filesystem is case-sensitive and only check if so?

Is it safe to always assume that the current system is the ultimate deployment target?

@parkr
Copy link
Member

parkr commented Nov 30, 2014

This is true! Ok, cool. @mattr- / @alfredxing, what do you think about this? Thanks for writing this up, @akoeplinger!

@alfredxing
Copy link
Member

👍 This is definitely useful, thanks for the PR!

urls[dest.downcase] = [dest]
end
end
urls
Copy link
Member

Choose a reason for hiding this comment

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

How about

things.inject(urls) do |memo, thing|
  dest = thing.destination(destination)
  (memo[dest.downcase] ||= []) << dest
  memo
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks good, pushed it.

@akoeplinger
Copy link
Contributor Author

Is there anything else here I need to do?

@parkr
Copy link
Member

parkr commented Dec 15, 2014

Looks good to me! @alfredxing? Thoughts?

@parkr
Copy link
Member

parkr commented Dec 15, 2014

I'm a bit concerned about performance but that's it.

@parkr
Copy link
Member

parkr commented Dec 15, 2014

Want to write a couple quick unit tests for this?

@akoeplinger
Copy link
Contributor Author

I'm a bit concerned about performance but that's it.

I tested on our website with ~2200 files and jekyll doctor takes 1.208s with this change and 1.192s without, so it's barely noticeable.

I'll take a look at adding some unit tests.

@alfredxing
Copy link
Member

Looks good! I was a bit concerned about performance as well but it doesn't seem to bad based on @akoeplinger's stats.

@akoeplinger
Copy link
Contributor Author

Hey guys, I added some tests here: akoeplinger@34ff0bb

I'm not really happy with them as I needed to make these two separate folders for the site source (I couldn't get anything in-memory working, basically cause I have zero insight into how the Jekyll internals work together), would be glad to hear a better approach.


should 'return success on a valid site/page' do
@site = Site.new(Jekyll.configuration({
"source" => File.join(source_dir, '/_urls_differ_by_case_valid'),
Copy link
Member

Choose a reason for hiding this comment

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

You can use source_dir('_urls_differ_by_case_valid') here – it does all the joining for you :)

@mattr-
Copy link
Member

mattr- commented Jan 2, 2015

domain names are case sensitive according to RFC 4353. The rest is up to how the server wants to handle GET requests, but I'd rather eliminate the possibility of any duplicates due to case-sensitivity, so 👍 on this.

@akoeplinger It looks like there are some missing tests to add. Would you mind taking care of those so we can merge this?

@parkr
Copy link
Member

parkr commented Jan 12, 2015

@akoeplinger It looks like there are some missing tests to add. Would you mind taking care of those so we can merge this?

👍

@parkr
Copy link
Member

parkr commented Jan 17, 2015

Still interested in seeing this @akoeplinger?

@akoeplinger
Copy link
Contributor Author

@parkr ahh sorry guys, I totally missed the notifications here and was busy with other stuff. I'll add the tests tomorrow :)

@parkr
Copy link
Member

parkr commented Feb 14, 2015

@akoeplinger Any updates?

@parkr parkr merged commit 34ff0bb into jekyll:master Dec 13, 2015
@parkr
Copy link
Member

parkr commented Dec 13, 2015

Merged in fdcd761.

parkr added a commit that referenced this pull request Dec 13, 2015
@akoeplinger
Copy link
Contributor Author

@parkr omg, no idea how this fell off my radar, sorry for the lack of updates 😭 Thanks for merging!

@akoeplinger akoeplinger deleted the doctor-permalink-same-case-warning branch December 14, 2015 14:55
@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jekyll doctor should print a warning if two permalinks only differ by case
6 participants