'AppleScript: Expected end of line, etc. but found identifier for if block

I am trying to open Photoshop when my custom URL is typed in the browser

Following is the applescript am trying to compile

on open location this_URL
    if (this_URL contains "authenticate") then
        if application "Adobe Photoshop CC 2022" is running then
            tell application "Adobe Photoshop CC 2022"
                activate
                do javascript of file "/Applications/myApp/photoshop_open.jsx" with arguments {1, this_URL}
            end tell
        end if
    end if
    if (this_URL contains "default") then
        display alert "Files cannot be opened natively on the Mac"
    end if
    if (this_URL contains "photoshop") then
        tell application "Adobe Photoshop CC 2022"
            activate
            delay 2
            do javascript of file "/Applications/myApp/photoshop_open.jsx" with arguments {1, this_URL}
        end tell
    end if
    if (this_URL contains "illustrator") then
        display alert "Files cannot be opened in Illustrator on the Mac"
    end if
end open location

But i run into an error

error: Expected end of line, etc. but found identifier. (-2741)

The error points to

if (this_URL contains "photoshop") then

Have been trying to find solution to the issue for past 2 days. Thanks in advance for suggestions and helps



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source