LPS-43142 making the fix more robust by checking for portalURL before returning the substring