Better whitespace support in IOHelper.ToCleanFileName

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/20/2011 11:03:51 AM
Gravatar
Total Posts 76

Better whitespace support in IOHelper.ToCleanFileName

This is really a very small issue.

I was adding some images to an Image Gallery Module.

The way we had the images stored on our network is with spaces between the words.

example: "sally sells seashells - at the seashore.jpg"

I noticed the ToCleanFileName strips the whitespaces... so the file looses some "meaning" to google

"sally sells seashells - at the seashore.jpg" --> "sallysellsseashells-attheseashore.jpg".

 

I removed a the .Replace(" ", string.Empty) and added a regex replace

string pattern =  @"(\s)+(-)*(\s)*";
return Regex.Replace(s, pattern, "-")

this makes the file name a little better from a web perspective

"sally sells seashells - at the seashore.jpg" --> "sally-sells-seashells-at-the-seashore.jpg"

I know the base cause is the way we name images on  our local network, but thought in the case of files served by the web server that "-" for spaces is better

Thoughts?

6/21/2011 11:43:03 AM
Gravatar
Total Posts 18439

Re: Better whitespace support in IOHelper.ToCleanFileName

Hi Warner,

I will change it replace multiple spaces with a single space and then to replace single spaces with - instead of empty string. It is a good idea.

Best,

Joe

6/22/2011 8:27:48 AM
Gravatar
Total Posts 76

Re: Better whitespace support in IOHelper.ToCleanFileName

 

Glad I could help~ :)

11/9/2011 3:27:49 PM
Gravatar
Total Posts 76

Re: Better whitespace support in IOHelper.ToCleanFileName

Joe

i noticed that

public static string ToCleanFileName(this string s, bool forceLowerCase)

and

public static string ToCleanFolderName(this string s, bool forceLowerCase)

Do not convert the space to dash. I would think these 2 should.

thoughts?

11/9/2011 3:44:20 PM
Gravatar
Total Posts 18439

Re: Better whitespace support in IOHelper.ToCleanFileName

sounds reasonable to me, I will make that change.

Best,

Joe

11/10/2011 9:35:24 AM
Gravatar
Total Posts 76

Re: Better whitespace support in IOHelper.ToCleanFileName

Will make for some longer urls... but i think the added SEO benefit will be enjoyed by everyone. :)

You must sign in to post in the forums. This thread is closed to new posts.