[SalesForce] Error with Self-registration Lightning Component on Napili Community

I am trying to use the standard self-registration lightning component to get the capability for the external users to create a new user account in the community.
On the Community's administration, I have already enabled : 'Allow external users to self-register', Chosen the Register community page, added my community profile and appended a temporary account.

Used the Lightning component: selfRegister on the Register community page.
When I try to register with some test data, I am getting this error: Ending position out of bounds: -1 I didn't made any changes to any of the code in the Ltng component or controller class. What I am doing wrong here? Just trying to make use of OOB functionality which is not working.

Referred this doc:

  1. Salesforce
    Self-Registration

Screenshot: enter image description here

Some suggestions/references/workarounds would be really appreciated.

Best Answer

Alright folks, I couldn't get this issue resolved here. So in my research, I found this issue as a Salesforce Known Issue which was opened two weeks prior to my post.

As the fix was mentioned: SCHEDULED - SPRING '18, I have reached out to Salesforce to get this solved at least in my Org as this is a Standard functionality. Thanks to Salesforce, they guided me where to look and provided me with the code to fix it. Here it is:

LightningSelfRegisterController.apxc

Use Network.getLoginUrl(networkId) or Network.communitiesLanding() to fetch the community url and then use it in the code to pass on instead of the networkId

String commURL = Network.getLoginUrl(networkId);

if(networkId != null && siteAsContainerEnabled(commURL)) { 
    u.put('UserPreferencesHideS1BrowserUI',true); 
}

Hope this helps someone who ran into this issue after Winter 18 release.