SNTT adding http onto URL strings in Lotus Notes

The challenge was to have end users enter url’s (or uri’s) for content and have it presented as a link on the read only end part of the site. The problem is that means having “http” (or “https”) -which indicates Hypertext Transfer Protocol – appended to the string, if it was not supplied by the end user.

so in the Input Translational part of the editable field I used the following formula :

1
2
3
4
5
tempUrl := @ReplaceSubstring(@Trim(@ThisValue); @Char(0) : " "; "");
testUrl := @UpperCase(tempUrl );
@If(tempUrl  = "";@Return("");
@Begins(testUrl ;"HTTPS://") | @Begins(testUrl ;"HTTP://"); tempUrl ;
"http://"+tempUrl )

what’s going on here?
1) doing a quick stripping out of blank spaces
2) making a copy of that result which is all Upper case
3) if the result is a blank string retun a blank string and stop
4) test if the string starts with http or https already properly appended, if so the return the string
5) if not, then appended “http://” to string.

a couple of notes: a) All modern browsers assume “http://” so you don’t need to type that into the address bars, but for a anchor link href the “http” (or some other protocol) is required for external references. b) And “www.” is not required and any sensible web site will work with either “www.domainName” or “domainName”. indeed “www.” is not used for (and breaks) sub domains (”subDomain.domainName”)

of course a more interesting problem would be validating those url’s!

This entry was posted in Lotus Domino, Show-n-Tell+Thursday. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
  • Follow

  • Archives (since 2003)

  • Categories

  • Recent Posts

  • Twitter Updates

    • I liked a YouTube video -- Recycle your unwanted electronics - City of Toronto http://youtu.be/91OXkMkesBc?a 13 hours ago
    • I'm organizing and coordinating my Japan Trip with Google Wave. Seeing both the promise and the fail. of the product. 19 hours ago
    • I have failed my saving Throw against Shiny ... I new 32G iPod Touch is on order :) 1 day ago
  • del.icio.us links

  • Flickr

    Hanging Gardens of KensingtonHanging Gardens of KensingtonMore Chocolate CakeMore Chocolate Cake
  •  

    August 2009
    M T W T F S S
    « Jul   Sep »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • Spam Blocked