Use AppleScipt to "Coralize" a URL?

Hi, I know a bit about AppleScript already, but I’m a bit confused with all these “text item delimiters” and whatnot.

I’m trying to ‘coralize’ a web address so it accesses a cache from the CoralCDN, a commonly used cache for site that have been ‘dugg’ or ‘/.ed’ or whatever.

You can learn about it at http://www.coralcdn.org/

It would turn something like this:
http://www.apple.com/support/tiger/internet/
into:
http://www.apple.com.nyud.net:8080/support/tiger/internet/

What I can’t do is stick the “.nyud.net:8080” in between the ‘.com’ and ‘/’. I need it to also regonize some other .whatevers, like .net, .us, .tk, and it’s giving me a headache.

How do I go about doing this?

This handler that I made to workout domain names, find in code exchange here. Just add a bit to the suffix, not to hard. Post a full URL before and after and I can do it for you, if you get stuck.

This should work for you

set theUrl to "http://www.apple.com/support/tiger/internet/"
set text item delimiters to {"/"}
try
	tell theUrl to set coralURL to text items 1 thru 2 & (text item 3 & ".nyud.net:8080") & text items 4 through -1 as Unicode text
on error
	tell theUrl to set coralURL to text items 1 thru 2 & (text item 3 & ".nyud.net:8080") as Unicode text
end try
set text item delimiters to {""}

Wow, thanks for the fast replies!

Thanks for the quick fix, James.

I’m also going to take a look at bevos’ homepage script too.

Small nitpick James; I would preserve the class of the input. (Besides me just thinking that it’s proper, it should be noted that StandardAdditions’ URL class currently does not support Unicode text.)

on coralizeURL(someURL)
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "/"
	
	try
		tell someURL to set someURL to "" & text items 1 thru 2 & ("/" & text item 3 & ".nyud.net:8080/") & text items 4 thru -1
	on error
		tell someURL to set someURL to "" & text items 1 thru 2 & ("/" & text item 3 & ".nyud.net:8080/")
	end try
	
	set AppleScript's text item delimiters to ASTID
	return someURL
end coralizeURL

coralizeURL("http://www.apple.com/support/tiger/internet/")
--> "http://www.apple.com.nyud.net:8080/support/tiger/internet/"

Ahh, didnt even think to check that Bruce, thanks for the nitpick :smiley: