@@ -2371,7 +2371,8 @@ function share(thisbutton) {
2371
2371
newdatastring = thisdata ? "&d=" + dataparam : "" , // construct data param if exists
2372
2372
isipfs = glob_thishostname . includes ( "ipfs" ) || glob_thishostname . includes ( "bitrequest.crypto" ) ,
2373
2373
shared_host = isipfs ? glob_c_host : "https://bitrequest.github.io" , // check for IFPS
2374
- sharedurl = shared_host + "/?p=requests&payment=" + payment + "&uoa=" + thiscurrency + "&amount=" + thisamount + "&address=" + thisaddress + newdatastring ,
2374
+ url_id = shared_host + "/?p=requests&payment=" + payment + "&uoa=" + thiscurrency + "&amount=" + thisamount + "&address=" + thisaddress ,
2375
+ sharedurl = url_id + newdatastring ,
2375
2376
thisrequestname_uppercase = capitalize ( thisrequestname ) , // capitalize requestname
2376
2377
paymentupper = capitalize ( payment ) ,
2377
2378
payment_name = lightning ? "Lightning" : paymentupper ,
@@ -2392,7 +2393,8 @@ function share(thisbutton) {
2392
2393
setlocales ( ) ;
2393
2394
return
2394
2395
}
2395
- shorten_url ( sharedtitle , sharedurl , share_icon ) ;
2396
+ const url_hash = hashcode ( url_id + sharedtitle ) ;
2397
+ shorten_url ( sharedtitle , sharedurl , share_icon , null , url_hash ) ;
2396
2398
setlocales ( ) ;
2397
2399
return
2398
2400
@@ -2413,43 +2415,43 @@ function share(thisbutton) {
2413
2415
}
2414
2416
2415
2417
// Handles URL shortening and sharing process
2416
- function shorten_url ( sharedtitle , sharedurl , sitethumb , unguessable ) {
2418
+ function shorten_url ( sharedtitle , sharedurl , sitethumb , unguessable , url_hash ) {
2417
2419
loadertext ( translate ( "generatelink" ) ) ;
2418
2420
const us_settings = $ ( "#url_shorten_settings" ) ,
2419
2421
us_active = us_settings . data ( "us_active" ) === "active" ;
2420
2422
if ( us_active ) {
2421
2423
const us_service = us_settings . data ( "selected" ) ,
2422
2424
is_custom = us_service . indexOf ( "https://" ) >= 0 ;
2423
- cache_prefix = is_custom ? "custom" : us_service ,
2424
- getcache = br_get_session ( cache_prefix + "_shorturl_" + hashcode ( sharedurl ) ) ;
2425
- if ( getcache ) {
2426
- sharerequest ( getcache , sharedtitle ) ;
2427
- return ;
2425
+ if ( url_hash ) {
2426
+ const cache_prefix = is_custom ? "custom" : us_service ,
2427
+ getcache = br_get_session ( cache_prefix + "_shorturl_" + url_hash ) ;
2428
+ if ( getcache ) {
2429
+ sharerequest ( getcache , sharedtitle ) ;
2430
+ return ;
2431
+ }
2428
2432
}
2429
2433
if ( us_service === "firebase" ) {
2430
- firebase_shorten ( sharedurl , sharedtitle , sitethumb , unguessable ) ;
2434
+ firebase_shorten ( sharedurl , sharedtitle , sitethumb , unguessable , url_hash ) ;
2431
2435
return ;
2432
2436
}
2433
2437
if ( us_service === "bitly" ) {
2434
- bitly_shorten ( sharedurl , sharedtitle ) ;
2438
+ bitly_shorten ( sharedurl , sharedtitle , url_hash ) ;
2435
2439
return ;
2436
2440
}
2437
2441
if ( is_custom ) {
2438
- custom_shorten ( us_service , sharedurl , sharedtitle , sitethumb ) ;
2442
+ custom_shorten ( us_service , sharedurl , sharedtitle , sitethumb , url_hash ) ;
2439
2443
return ;
2440
2444
}
2441
2445
}
2442
2446
sharerequest ( sharedurl , sharedtitle ) ;
2443
2447
}
2444
2448
2445
2449
// Handles Firebase URL shortening
2446
- function firebase_shorten ( sharedurl , sharedtitle , sitethumb , unguessable ) {
2450
+ function firebase_shorten ( sharedurl , sharedtitle , sitethumb , unguessable , url_hash ) {
2447
2451
const security = unguessable ? "UNGUESSABLE" : "SHORT" ;
2448
2452
api_proxy ( {
2449
2453
"api" : "firebase" ,
2450
2454
"search" : "shortLinks" ,
2451
- "cachetime" : 84600 ,
2452
- "cachefolder" : "1d" ,
2453
2455
"params" : {
2454
2456
"method" : "POST" ,
2455
2457
"cache" : false ,
@@ -2482,24 +2484,26 @@ function firebase_shorten(sharedurl, sharedtitle, sitethumb, unguessable) {
2482
2484
const data = br_result ( e ) . result ;
2483
2485
if ( data ) {
2484
2486
if ( data . error ) {
2485
- custom_shorten ( false , sharedurl , sharedtitle , sitethumb ) ;
2487
+ custom_shorten ( false , sharedurl , sharedtitle , sitethumb , url_hash ) ;
2486
2488
return
2487
2489
}
2488
2490
const shorturl = data . shortLink ;
2489
2491
if ( shorturl ) {
2490
2492
sharerequest ( shorturl , sharedtitle ) ;
2491
- br_set_session ( "firebase_shorturl_" + hashcode ( sharedurl ) , shorturl ) ;
2493
+ if ( url_hash ) {
2494
+ br_set_session ( "firebase_shorturl_" + url_hash , shorturl ) ;
2495
+ }
2492
2496
return
2493
2497
}
2494
2498
}
2495
- custom_shorten ( false , sharedurl , sharedtitle , sitethumb ) ;
2499
+ custom_shorten ( false , sharedurl , sharedtitle , sitethumb , url_hash ) ;
2496
2500
} ) . fail ( function ( ) {
2497
- custom_shorten ( false , sharedurl , sharedtitle , sitethumb ) ;
2501
+ custom_shorten ( false , sharedurl , sharedtitle , sitethumb , url_hash ) ;
2498
2502
} ) ;
2499
2503
}
2500
2504
2501
2505
// Handles Bitly URL shortening
2502
- function bitly_shorten ( sharedurl , sharedtitle ) {
2506
+ function bitly_shorten ( sharedurl , sharedtitle , url_hash ) {
2503
2507
api_proxy ( {
2504
2508
"api" : "bitly" ,
2505
2509
"search" : "bitlinks" ,
@@ -2519,7 +2523,9 @@ function bitly_shorten(sharedurl, sharedtitle) {
2519
2523
const linkid = data . id . split ( "/" ) . pop ( ) ,
2520
2524
shurl = glob_approot + "?i=4bR" + linkid ;
2521
2525
sharerequest ( shurl , sharedtitle ) ;
2522
- br_set_session ( "bitly_shorturl_" + hashcode ( sharedurl ) , shurl ) ;
2526
+ if ( url_hash ) {
2527
+ br_set_session ( "bitly_shorturl_" + url_hash , shurl ) ;
2528
+ }
2523
2529
return
2524
2530
}
2525
2531
sharerequest ( sharedurl , sharedtitle ) ;
@@ -2529,7 +2535,7 @@ function bitly_shorten(sharedurl, sharedtitle) {
2529
2535
}
2530
2536
2531
2537
// Handles Custom URL shortening
2532
- function custom_shorten ( service , sharedurl , sharedtitle , sitethumb ) {
2538
+ function custom_shorten ( service , sharedurl , sharedtitle , sitethumb , url_hash ) {
2533
2539
const serv = service || d_proxy ( ) ,
2534
2540
rqdat = btoa ( JSON . stringify ( {
2535
2541
"sharedurl" : sharedurl ,
@@ -2552,7 +2558,7 @@ function custom_shorten(service, sharedurl, sharedtitle, sitethumb) {
2552
2558
if ( data ) {
2553
2559
if ( data . error ) {
2554
2560
notify ( serv + ": " + data . error , 500000 , "yes" ) ;
2555
- bitly_shorten ( sharedurl , sharedtitle ) ;
2561
+ bitly_shorten ( sharedurl , sharedtitle , url_hash ) ;
2556
2562
return
2557
2563
}
2558
2564
const rqid = data . shorturl ;
@@ -2561,13 +2567,15 @@ function custom_shorten(service, sharedurl, sharedtitle, sitethumb) {
2561
2567
isdefault = index > - 1 ;
2562
2568
shurl = isdefault ? glob_approot + "?i=" + index . toString ( ) + rqid : serv + "proxy/v1/inv/4bR" + rqid ;
2563
2569
sharerequest ( shurl , sharedtitle ) ;
2564
- br_set_session ( "custom_shorturl_" + hashcode ( sharedurl ) , shurl ) ;
2570
+ if ( url_hash ) {
2571
+ br_set_session ( "custom_shorturl_" + url_hash , shurl ) ;
2572
+ }
2565
2573
return
2566
2574
}
2567
2575
}
2568
- bitly_shorten ( sharedurl , sharedtitle ) ;
2576
+ bitly_shorten ( sharedurl , sharedtitle , url_hash ) ;
2569
2577
} ) . fail ( function ( ) {
2570
- bitly_shorten ( sharedurl , sharedtitle ) ;
2578
+ bitly_shorten ( sharedurl , sharedtitle , url_hash ) ;
2571
2579
} ) ;
2572
2580
}
2573
2581
0 commit comments