p5-shorten / www-shorten

Perl interface to various URL-shortening sites
https://metacpan.org/release/WWW-Shorten
Other
12 stars 9 forks source link

tinyurl.com is now returning http:// URL #17

Closed derekschrock closed 2 years ago

derekschrock commented 2 years ago

A year later #14 tinyurl.com is back to returning http:// links. I've filed a ticket to see if this is expected. Report back once/if they reply. However, it seems that maybe reverting that PR could be the fix.

derekschrock commented 2 years ago

At least for the time being to fix the shortener:

--- /usr/local/lib/perl5/site_perl/WWW/Shorten/TinyURL.pm       2021-03-12 12:48:25.000000000 -0500
+++ TinyURL.pm  2022-07-03 00:55:47.737290000 -0400
@@ -41,7 +41,7 @@
         }
         return undef;
     }
-    if ($resp->content =~ m!(\Qhttps://tinyurl.com/\E\w+)!x) {
+    if ($resp->content =~ m!(https?://tinyurl.com/\w+)!x) {
         return $1;
     }
     return;
@@ -52,7 +52,7 @@
         or Carp::croak('No TinyURL key / URL passed to makealongerlink');
     $_error_message = '';
     $url = "https://tinyurl.com/$url"
-        unless $url =~ m!^https://!i;
+        unless $url =~ m!^https?://!i;

     # terrible, bad!  skip live testing for now.
     if ( $ENV{'WWW-SHORTEN-TESTING'} ) {
davorg commented 2 years ago

@derekschrock Could you please submit this as a PR. Thanks.

derekschrock commented 2 years ago

tinyurl.com fixed it on their end. It's now returning https:// links.

davorg commented 2 years ago

But I'm thinking we should still implement your fix in case it breaks again in the future.

derekschrock commented 2 years ago

Yeah, I was thinking the same thing. I'll take a look at it this week to make it work with both http and https for shorter and longer.