Skip to content

Bug in method RailsAdmin::Support::Datetime#to_momentjs #3009

@enthusiasmus

Description

@enthusiasmus

When the strftime_format equals %Y-%m-%dT%H:%M:%S%:z the method to_momentjs returns %Y-%m-%[dT]%H:%M:%S%:z. Which is incorrect, because I don't want to have dT to be escaped. Whats the reson for the two regexes?

Method:

def to_momentjs
  strftime_format.gsub(/\w[^.(!?%)\W]{1,}/, '[\0]').gsub(/%(\w|\-\w)/) do |match|
    MOMENTJS_TRANSLATIONS[match]
  end
end

File: https://github.com/sferik/rails_admin/blob/c9323f69ae60f14eb31fea62c05f5f0e55cbea34/lib/rails_admin/support/datetime.rb
Version: 1.3.0

The result is a broken between ... and Filter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions