For reasons that only the developers can understand, Firefox will create and open .url files on Windows and .webloc files on OS X but won't allow the Windows version of Firefox to open .webloc files or the OS X version of Firefox to open .url files. (.url files open in Safari but that's not good enough for reasons that aren't worth going into here.) As part of my efforts to use either filetype on either system, I'm writing an applescript to open .url files on OS X Firefox.
on open the_droppings
set filePath to the_droppings
set fp to open for access filePath
set fileContents to read fp
close access fp
set secondLine to paragraph 2 of fileContents
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "="
set URLstring to last text item of secondLine
set AppleScript's text item delimiters to tid
tell application "Firefox"
activate
OpenURL URLstring
end tell
end open
I thought this would work but in the 3rd to last line it says "Expected end of line, etc. but found identifier." Why is this?
EDIT sakra's answer below mostly works but breaks on urls containing "=" such as: http://example.com?foo=a&bar=z