镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Potential Typo in REXML::Functions::normalize_space() Implementation #110

Closed

Description

@flatland001

Hello Ruby/REXML developers,

The implementation can be found here:

https://github.com/ruby/rexml/blob/7e4049f6a68c99c4efec2df117057ee080680c9f/lib/rexml/functions.rb#L265C1-L273C8

The current code is as follows:

    # UNTESTED
    def Functions::normalize_space( string=nil )
      string = string(@@context[:node]) if string.nil?
      if string.kind_of? Array
        string.collect{|x| string.to_s.strip.gsub(/\s+/um, ' ') if string}
      else
        string.to_s.strip.gsub(/\s+/um, ' ')
      end
    end

It appears there may be a typo in the use of x versus string within the collect block. I believe the following adjustment might be more in line with the intended functionality:

string.collect{|x| x.to_s.strip.gsub(/\s+/um, ' ') if x}

I might be misunderstanding the intention here, so if I've overlooked something, please do let me know.
Thank you for your time.

Activity

  1. kou commented on Feb 7, 2024

    @kou
    Member

    Good catch!
    Could you open a PR for this?
    (It's better that it has a test for this case.)

  2. added a commit that references this issue on Feb 8, 2024
    444c9ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions