@@ -18,7 +18,8 @@ export default class HomeComponent extends Component {
1818 usedSettings : this . urlParams . get ( 'customUrl' ) ? [ 'custom' ] : [ ] ,
1919 customID : this . urlParams . get ( 'customUrl' ) ? this . urlParams . get ( 'customUrl' ) : '' ,
2020 showCustomIDError : false ,
21- expiration : null
21+ expiration : null ,
22+ displayURL : window . location . origin
2223 }
2324 }
2425 handleURLChange = ( e , { value } ) => this . url = value
@@ -31,12 +32,13 @@ export default class HomeComponent extends Component {
3132 onSettingsChange = ( e , { value } ) => {
3233 this . setState ( { usedSettings : value } )
3334 }
34-
35-
3635
37-
36+
3837 componentDidMount ( ) {
3938 this . urlInput . focus ( )
39+ fetch ( "/displayurl" )
40+ . then ( response => response . json ( ) )
41+ . then ( data => this . setState ( { displayURL : data } ) ) ;
4042 }
4143 handleURLSubmit = ( ) => {
4244 if ( ! this . state . showCustomIDError ) {
@@ -47,7 +49,7 @@ export default class HomeComponent extends Component {
4749 Password : this . state . usedSettings . includes ( "protected" ) && this . password ? this . password : undefined
4850 } , r => this . setState ( {
4951 links : [ ...this . state . links , {
50- shortenedURL : r . URL ,
52+ shortenedURL : this . state . displayURL + "/" + this . state . customID ,
5153 originalURL : this . url ,
5254 expiration : this . state . usedSettings . includes ( "expire" ) && this . state . expiration ? this . state . expiration . toISOString ( ) : undefined ,
5355 deletionURL : r . DeletionURL
@@ -89,7 +91,7 @@ export default class HomeComponent extends Component {
8991 </ MediaQuery >
9092 < Form . Group style = { { marginBottom : "1rem" } } >
9193 { usedSettings . includes ( "custom" ) && < Form . Field error = { showCustomIDError } width = { 16 } >
92- < Input label = { window . location . origin + "/" } onChange = { this . handleCustomIDChange } placeholder = 'my-shortened-url' value = { this . state . customID } />
94+ < Input label = { this . state . displayURL + "/" } onChange = { this . handleCustomIDChange } placeholder = 'my-shortened-url' value = { this . state . customID } />
9395 </ Form . Field > }
9496 </ Form . Group >
9597 < Form . Group widths = "equal" >
0 commit comments