wiki pages: fix normalization of wiki page title.
Fix the wiki page title "azur___lane" being normalized to "azur__lane" instead of "azur_lane".
This commit is contained in:
@@ -150,7 +150,7 @@ class WikiPage < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.normalize_title(title)
|
||||
title.to_s.downcase.delete_prefix("~").gsub(/[[:space:]]+/, "_").gsub(/__/, "_").gsub(/\A_|_\z/, "")
|
||||
title.to_s.downcase.delete_prefix("~").gsub(/[[:space:]]+/, "_").squeeze("_").gsub(/\A_|_\z/, "")
|
||||
end
|
||||
|
||||
def normalize_other_names
|
||||
|
||||
@@ -98,7 +98,10 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
should normalize_attribute(:title).from("foo_").to("foo")
|
||||
should normalize_attribute(:title).from("FOO").to("foo")
|
||||
should normalize_attribute(:title).from("foo__bar").to("foo_bar")
|
||||
should normalize_attribute(:title).from("foo___bar").to("foo_bar")
|
||||
should normalize_attribute(:title).from("___foo___bar___").to("foo_bar")
|
||||
should normalize_attribute(:title).from("foo bar").to("foo_bar")
|
||||
should normalize_attribute(:title).from(" Foo___ Bar ").to("foo_bar")
|
||||
|
||||
should_not allow_value("").for(:title).on(:create)
|
||||
should_not allow_value("___").for(:title).on(:create)
|
||||
|
||||
Reference in New Issue
Block a user