mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Remove all leading dots and spaces
This commit is contained in:
parent
ccf558eaa7
commit
566cebfcdd
@ -68,6 +68,6 @@ describe "sanitize_filename" do
|
|||||||
end
|
end
|
||||||
it "sanitizes correctly" do
|
it "sanitizes correctly" do
|
||||||
sanitize_filename(".. \n\v.\rマンゴー/|*()<[1/2] 3.14 hello world ")
|
sanitize_filename(".. \n\v.\rマンゴー/|*()<[1/2] 3.14 hello world ")
|
||||||
.should eq " . マンゴー_()[1_2] 3.14 hello world"
|
.should eq "マンゴー_()[1_2] 3.14 hello world"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -135,7 +135,7 @@ def sanitize_filename(str : String) : String
|
|||||||
.gsub(/\s+/, " ")
|
.gsub(/\s+/, " ")
|
||||||
.strip
|
.strip
|
||||||
.gsub(/\//, "_")
|
.gsub(/\//, "_")
|
||||||
.gsub(/^\.+/, "")
|
.gsub(/^[\.\s]+/, "")
|
||||||
.gsub(/[\177\000-\031\\:\*\?\"<>\|]/, "")
|
.gsub(/[\177\000-\031\\:\*\?\"<>\|]/, "")
|
||||||
sanitized.size > 0 ? sanitized : random_str
|
sanitized.size > 0 ? sanitized : random_str
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user