remove account status prefix from parsed page
This commit is contained in:
@@ -8,6 +8,15 @@ class Domain::Fa::Parser::UserPageHelper < Domain::Fa::Parser::Base
|
||||
@page_version = page_version
|
||||
end
|
||||
|
||||
# https://webcache.googleusercontent.com/search?q=cache:L85loB7VJXwJ:https://forums.furaffinity.net/threads/question-about-the-username-prefix.1655691/&cd=10&hl=en&ct=clnk&gl=us
|
||||
PREFIXES = [
|
||||
"~", # regular user
|
||||
"!", # suspended
|
||||
"-", # banned (permanent)
|
||||
"@", # admin
|
||||
"∞", # deceased
|
||||
]
|
||||
|
||||
def name
|
||||
# user names are in the form "~username", so strip the first
|
||||
# char from the user's name
|
||||
@@ -21,11 +30,18 @@ class Domain::Fa::Parser::UserPageHelper < Domain::Fa::Parser::Base
|
||||
unimplemented_version!
|
||||
end
|
||||
|
||||
elem&.
|
||||
name = elem&.
|
||||
first&.
|
||||
text&.
|
||||
strip&.
|
||||
delete_prefix("~")
|
||||
strip
|
||||
|
||||
if name
|
||||
if PREFIXES.include?(name[0])
|
||||
name[1..]
|
||||
else
|
||||
raise("invalid prefix for name: #{name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -72,7 +72,14 @@ class Domain::Fa::User < ReduxApplicationRecord
|
||||
if url_name && url_name =~ /[A-Z]/
|
||||
errors.add(
|
||||
:url_name,
|
||||
"url_name #{url_name} contains uppercase chars"
|
||||
"url_name '#{url_name}' contains uppercase"
|
||||
)
|
||||
end
|
||||
|
||||
if url_name && url_name =~ /\s/
|
||||
errors.add(
|
||||
:url_name,
|
||||
"url_name '#{url_name}' contains whitespace"
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -162,8 +169,6 @@ class Domain::Fa::User < ReduxApplicationRecord
|
||||
name = name.strip
|
||||
URL_NAME_EXCEPTIONS[name] || name.
|
||||
delete("_").
|
||||
delete("!").
|
||||
delete("∞").
|
||||
downcase
|
||||
end
|
||||
|
||||
|
||||
@@ -71,6 +71,13 @@ describe Domain::Fa::User do
|
||||
}).errors.full_messages).to_not be_empty
|
||||
end
|
||||
|
||||
it "cannot contain whitespace" do
|
||||
expect(described_class.create({
|
||||
name: "Foo",
|
||||
url_name: "foo ",
|
||||
}).errors.full_messages).to_not be_empty
|
||||
end
|
||||
|
||||
it "posts can be moved from one user to another" do
|
||||
user1 = SpecUtil.create_domain_fa_user(name: "Foo", url_name: "foo")
|
||||
user2 = SpecUtil.create_domain_fa_user(name: "Bar", url_name: "bar")
|
||||
|
||||
Reference in New Issue
Block a user