Skip to content

modules/auxiliary/crawler: Resolve RuboCop violations #20193

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: master
Choose a base branch
from

Conversation

bcoles
Copy link
Contributor

@bcoles bcoles commented May 15, 2025

Most violations resolved with rubocop -A, except notes.

  • Fixes a bug due to a typo where @curent_site was used instead of @current_site.
  • Replaces multiple tabs with spaces

There are likely many bugs still present. I'm not interested in fixing them. I'm especially not interested in fixing the canonicalize method.

@bcoles bcoles added the code quality Improving code quality label May 15, 2025
end

# Taken from http://www.ruby-forum.com/topic/140101 by Rob Biedenharn
# Abomonation taken from https://www.ruby-forum.com/t/creating-a-canonicalized-url/127036/6 by Rob Biedenharn
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be less of an abomination:

  def canonicalize(uri)
    uri = URI(uri) unless uri.is_a?(URI)
    uri.normalize!

    path = uri.path.dup
    segments = path.split('/')
    resolved = []

    segments.each do |segment|
      next if segment == '.' || segment.empty?

      if segment == '..'
        resolved.pop unless resolved.empty?
      else
        resolved << segment
      end
    end

    uri.path = '/' + resolved.join('/')
    uri.to_s
  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.

You're welcome to implement this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improving code quality
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants