Re: Test for valid URL?
Re: Test for valid URL?
- Subject: Re: Test for valid URL?
- From: Michael Grant <email@hidden>
- Date: Thu, 16 Sep 2010 12:46:19 -0500
On Thu, Sep 16, 2010 at 5:38 AM, Steve Thompson <email@hidden> wrote:
>
> On 16 Sep 2010, at 01:48, Michael Grant wrote:
>
> Does AppleScript provide any way of testing whether a string is a
> valid URL before using it as the argument of the "open location"
> command?
>
> A couple of other people have mentioned that the word "valid" is ambiguous
> but for "standard" URLs this works
> try
> do shell script "curl http://hgghjgjhghj/"
> on error
> display dialog "No a valid URL"
> end try
> If curl can't resolve the url it returns an error which AppleScript's try
> statement can catch.
> Steve
Thanks to everyone who has replied so far. Actually I do want to be
able to respond to different protocols, not just http, for both local
and network resources. Unfortunately neither
open location "some random string"
nor
do shell script "curl some random string"
actually returns an error on my system (the first one returns nothing,
the second returns an empty string), and they both just fail silently
if I wrap them in Steve's try block.
Not really a big deal, I was hoping I could make my script beep if it
tries to open an invalid url, but I guess I can live with it just
failing silently.
Mark mentioned a syntax check, which would be better than nothing. Is
there a recipe you could point me to?
Thanks,
Michael
--
There's really no such thing as translating. It's all a scam. We
basically just make stuff up and try to make it sound plausible.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden