Skip to content

Fix duplicate path fragments from PathCleaner.clean #2150

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

richardboehme
Copy link

The PathCleaner generates path fragments according to the ruby constants. This works by splitting the uri path provided by ruby into class parts. When handling nested constants, the default class part list contains all constant fragments from the constant name except the last one.

We need to do this because the ruby docs sometimes do not include the parent class parts in the uri path. However sometimes they do include those parent class parts.

This led to class parts being duplicated in the cleaned path. One example of this is Thread::Queue#deq. The alias method path provided by ruby is "Thread/Queue" and the constant is "Thread::Queue". When cleaning the path we default to ['Thread'] and join "Thread" and "Queue" afterwards, resulting in the path thread/thread/queue which is not valid.

This patch tries to fix this by only adding new class parts if the new part does not already exist in the list of class parts.

Fixes #1748

The PathCleaner generates path fragments according to the ruby
constants. This works by splitting the uri path provided by ruby into
class parts. When handling nested constants, the default class part list
contains all constant fragments from the constant name except the last one.

We need to do this because the ruby docs sometimes do not include the
parent class parts in the uri path. However sometimes they do include
those parent class parts.

This led to class parts being duplicated in the cleaned path. One
example of this is `Thread::Queue#deq`. The alias method path provided
by ruby is "Thread/Queue" and the constant is "Thread::Queue". When
cleaning the path we default to `['Thread']` and join "Thread" and
"Queue" afterwards, resulting in the path `thread/thread/queue` which
is not valid.

This patch tries to fix this by only adding new class parts if the
new part does not already exist in the list of class parts.

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

Successfully merging this pull request may close these issues.

Link to Queue#pop is broken
1 participant