aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xform.cgi6
-rwxr-xr-xredirect.cgi1
2 files changed, 4 insertions, 3 deletions
diff --git a/form.cgi b/form.cgi
index 4e3f9d3..d9db8ba 100755
--- a/form.cgi
+++ b/form.cgi
@@ -26,10 +26,10 @@ if ($q->param('url')) {
# create database handler
my $dbh = DBI->connect("dbi:Pg:dbname=purl") or die $DBI::errstr;
-
+
# SQL Query
my $query = qq(SELECT shorts.url FROM shorts WHERE shorts.short = ?;);
-
+
# Check if short exists. If it does, generate a new one.
while (my $url = $dbh->selectrow_array($query, undef, $short)) {
$results .= "Your short exists. Generating new.<br>\n";
@@ -45,7 +45,7 @@ if ($q->param('url')) {
my $proto = $ENV{'HTTPS'} eq "on" ? 'https://' : 'http://'; # http/https
- my $shortURL = $proto . $ENV{'SERVER_NAME'} . '/' . $short;
+ my $shortURL = $proto . $ENV{'SERVER_NAME'} . '/+' . $short;
$results .= "URL: $url<br>\n";
$results .= "Shortened to: <a href=\"$shortURL\">$shortURL</a><br>\n";
$results .= "<hr>\n";
diff --git a/redirect.cgi b/redirect.cgi
index 9af5ed9..e95b74b 100755
--- a/redirect.cgi
+++ b/redirect.cgi
@@ -15,6 +15,7 @@ my $dbh = DBI->connect("dbi:Pg:dbname=purl") or die $DBI::errstr;
# set the short
my $short = scalar $ENV{REQUEST_URI};
$short =~ s/^\///;
+$short =~ s/^\+//; # If short starts with +, remove it.
# SQL Query
my $query = qq(SELECT shorts.url FROM shorts WHERE shorts.short = ?;);