fix script path detection method to account for links