Compare commits
10 Commits
917097b26a
...
3b44f3d633
Author | SHA1 | Date | |
---|---|---|---|
3b44f3d633 | |||
6c60acf5f2 | |||
a14d4f2aef | |||
a6cc0239ec | |||
c53041b906 | |||
db82f97921 | |||
befd600fbe | |||
|
a17f790832 | ||
|
62810c405a | ||
93f902a01a |
13
Dockerfile
13
Dockerfile
|
@ -1,4 +1,4 @@
|
||||||
FROM rakudo-star:2023.08
|
FROM docker.io/rakudo-star:2023.08
|
||||||
|
|
||||||
# Move it
|
# Move it
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
|
@ -11,15 +11,14 @@ COPY templates/ ./templates/
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get -y upgrade
|
RUN apt-get -y upgrade
|
||||||
RUN apt-get -y install libssl-dev libarchive-dev
|
RUN apt-get -y install libssl-dev libarchive-dev
|
||||||
# Stupid tests failing idk
|
# Tests failing cope
|
||||||
RUN zef -v install --force-test IO::Socket::Async::SSL \
|
RUN zef -v install --force-test IO::Socket::Async::SSL \
|
||||||
Archive::Libarchive::Raw NativeHelpers::Callback
|
NativeHelpers::Callback \
|
||||||
# Get the latest and greatest for bug fix
|
Archive::Libarchive::Raw
|
||||||
# https://github.com/rawleyfowler/Humming-Bird/issues/60#issuecomment-1788351265
|
|
||||||
RUN zef install https://github.com/rawleyfowler/Humming-Bird.git --force-install
|
|
||||||
RUN zef -v install --deps-only .
|
RUN zef -v install --deps-only .
|
||||||
|
|
||||||
# Finish setting up the environment
|
# Finish setting up the environment
|
||||||
|
ENV HUMMING_BIRD_ENV='PROD'
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["raku", "bin/hyperlink-redirect"]
|
CMD ["raku", "bin/hyperlink-redirect"]
|
||||||
|
|
|
@ -11,4 +11,4 @@ use Humming-Bird::Core;
|
||||||
use lib 'lib';
|
use lib 'lib';
|
||||||
use Hyperlink-Redirect;
|
use Hyperlink-Redirect;
|
||||||
|
|
||||||
listen(3000);
|
listen 3000;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
use Humming-Bird::Core;
|
use Humming-Bird::Core;
|
||||||
use Humming-Bird::Middleware;
|
|
||||||
use Humming-Bird::Advice;
|
|
||||||
use Template::Mustache;
|
use Template::Mustache;
|
||||||
|
|
||||||
# Normally would 'use' local libs here for Controller and Model and
|
# Normally would 'use' local libs here for Controller and Model and
|
||||||
|
@ -11,9 +9,8 @@ use Hyperlink-Redirect::Helpers;
|
||||||
# Set things up (config stuff would go here?)
|
# Set things up (config stuff would go here?)
|
||||||
my $template = Template::Mustache.new: :from<../templates>;
|
my $template = Template::Mustache.new: :from<../templates>;
|
||||||
|
|
||||||
# Logging
|
# Plugins
|
||||||
middleware &middleware-logger;
|
plugin 'Logger';
|
||||||
advice &advice-logger;
|
|
||||||
|
|
||||||
# Must set the root path lest yet miss setting $!root
|
# Must set the root path lest yet miss setting $!root
|
||||||
my $router = Router.new(root => '/');
|
my $router = Router.new(root => '/');
|
||||||
|
@ -41,6 +38,11 @@ $router.post(-> $request, $response {
|
||||||
$response.html($template.render: 'index', %stash);
|
$response.html($template.render: 'index', %stash);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# Don't try to process favicon as a hyperlink
|
||||||
|
$router.get('/favicon.ico', -> $request, $response {
|
||||||
|
$response.status(204)
|
||||||
|
});
|
||||||
|
|
||||||
# Process the hyperlink
|
# Process the hyperlink
|
||||||
$router.get('/--meta-refresh/**', -> $request, $response {
|
$router.get('/--meta-refresh/**', -> $request, $response {
|
||||||
my Str $return-url = $request.path.subst: /^ '/--meta-refresh/'/, Empty;
|
my Str $return-url = $request.path.subst: /^ '/--meta-refresh/'/, Empty;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use Libarchive::Filter :gzip;
|
||||||
|
|
||||||
my $starts-with-protocol = rx:i/ ^https? '://'/;
|
my $starts-with-protocol = rx:i/ ^https? '://'/;
|
||||||
|
|
||||||
sub fix-protocol($url) is export {
|
sub fix-protocol(Str $url) is export {
|
||||||
return "http://" ~ $url unless $url ~~ $starts-with-protocol;
|
return "http://" ~ $url unless $url ~~ $starts-with-protocol;
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
|
17
t/01-basic.rakutest
Normal file
17
t/01-basic.rakutest
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use v6.d;
|
||||||
|
use Humming-Bird::Core;
|
||||||
|
use Test;
|
||||||
|
# Local libs
|
||||||
|
use lib 'lib';
|
||||||
|
use Hyperlink-Redirect;
|
||||||
|
use Hyperlink-Redirect::Helpers;
|
||||||
|
|
||||||
|
plan 2;
|
||||||
|
|
||||||
|
ok fix-protocol("seriousbusiness.international") eq "http://seriousbusiness.international",
|
||||||
|
"fix-protocol fixes bare domains correctly"
|
||||||
|
or diag "\nfix-protocol should return the same string with 'http://' prefixed if protocol isn't specified";
|
||||||
|
|
||||||
|
ok fix-protocol("https://www.seriousbusiness.international") eq "https://www.seriousbusiness.international",
|
||||||
|
"fix-protocol does not mangle correctly formatted domains"
|
||||||
|
or diag "\nThe URL should remain unchanged when the protocol is specified";
|
Loading…
Reference in New Issue
Block a user