File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,18 @@ class IdpSelect extends React.Component {
2020 } ) )
2121
2222 handleChangeIdp = event => {
23- this . setState ( { customIdp : { url : event . target . value } } )
23+ let url = event . target . value
24+ // Auto-prepend https: if the user is not typing it
25+ if ( ! / ^ ( $ | h $ | h t ) / . test ( url ) ) url = `https://${ url } `
26+ this . setState ( { customIdp : { url } } )
27+ }
28+
29+ handleBlurIdp = event => {
30+ let url = event . target . value
31+ // Auto-prepend https: if not present
32+ if ( ! / ^ ( h t t p s ? : \/ \/ | $ ) / . test ( url ) )
33+ url = url . replace ( / ^ ( [ a - z ] * : \/ * ) ? / , 'https://' )
34+ this . setState ( { customIdp : { url } } )
2435 }
2536
2637 handleSelectIdp = idp => async event => {
@@ -67,9 +78,10 @@ class IdpSelect extends React.Component {
6778 < input
6879 ref = { input => ( this . idpInput = input ) }
6980 type = "url"
70- placeholder = "https://my-identity.databox.me/profile/card#me "
81+ placeholder = "https://my-identity.provider "
7182 value = { customIdp . url }
7283 onChange = { this . handleChangeIdp }
84+ onBlur = { this . handleBlurIdp }
7385 />
7486 < button type = "submit" > Log In</ button >
7587 < button type = "reset" onClick = { this . toggleEnteringCustomIdp } >
You can’t perform that action at this time.
0 commit comments