Move tracking asset to simplify proxy configuration
Change-Id: I01d2b196f48924aa17e9bc2d4187d69a8bf5b2d6
diff --git a/Changes b/Changes
index c684b1b..2fcb711 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.41 2021-02-16
+0.41 2021-02-22
- Introduce CORS headers to the proxy.
- Introduce Content Security Policy.
- Remove default api endpoint from config to
@@ -28,6 +28,8 @@
- Remove deprecated helper methods.
- Introduce Kalamar::Request and
kalamar->request helper.
+ - Move /js/tracking.js to /settings/asset/tracking.js
+ to simplify asset configuration in proxy servers.
0.40 2020-12-17
- Modernize ES and fix in-loops.
diff --git a/lib/Kalamar/Plugin/Piwik.pm b/lib/Kalamar/Plugin/Piwik.pm
index ca414ff..e1612f9 100644
--- a/lib/Kalamar/Plugin/Piwik.pm
+++ b/lib/Kalamar/Plugin/Piwik.pm
@@ -66,7 +66,7 @@
$mojo->csp->add('img-src' => $url);
# Set track script for CSP compliant tracking
- $mojo->routes->any('/js/tracking.js')->piwik('track_script');
+ $mojo->routes->any('/settings/assets/tracking.js')->piwik('track_script');
# Add piwik tag to scripts
$mojo->content_block(scripts => {
diff --git a/t/plugin/piwik.t b/t/plugin/piwik.t
index a2ad05c..cb4ba9d 100644
--- a/t/plugin/piwik.t
+++ b/t/plugin/piwik.t
@@ -23,7 +23,7 @@
->content_unlike(qr!setDocumentTitle!)
->content_unlike(qr!setCustomUrl!)
->content_unlike(qr!trackPageView!)
- ->element_exists('script[src$="/js/tracking.js"]')
+ ->element_exists('script[src$="/settings/assets/tracking.js"]')
;
$t = Test::Mojo->new('Kalamar' => {
@@ -37,21 +37,21 @@
$t->app->plugin('Kalamar::Plugin::Piwik');
-is($t->app->piwik_tag('as-script'), '<script src="/js/tracking.js"></script>' .
+is($t->app->piwik_tag('as-script'), '<script src="/settings/assets/tracking.js"></script>' .
'<script src="https://piwik.korap.ids-mannheim.de/piwik.js" async defer></script>');
$t->get_ok('/doc/faq')
->status_is(200)
->text_like('section[name=piwik-opt-out] h3', qr!can I opt-out!)
->element_exists('section[name=piwik-opt-out] iframe')
- ->element_exists('script[src$="/js/tracking.js"]')
+ ->element_exists('script[src$="/settings/assets/tracking.js"]')
->content_unlike(qr!_paq!)
->header_like('Content-Security-Policy',qr!connect-src 'self' [^;]*?https://piwik\.korap\.ids-mannheim\.de/!)
->header_like('Content-Security-Policy',qr!img-src 'self' [^;]*?https://piwik\.korap\.ids-mannheim\.de/!)
->header_like('Content-Security-Policy',qr!script-src 'self' [^;]*?https://piwik.korap.ids-mannheim.de/!)
;
-$t->get_ok('/js/tracking.js')
+$t->get_ok('/settings/assets/tracking.js')
->status_is(200)
->content_like(qr!var _paq!)
->content_like(qr!;console\.log\("fun"\)!)
@@ -74,7 +74,7 @@
->element_exists_not('section[name=piwik-opt-out] iframe')
->content_unlike(qr!_paq!)
->content_unlike(qr!window\.addEventListener\('korapRequest!)
- ->element_exists_not('script[src$="/js/tracking.js"]')
+ ->element_exists_not('script[src$="/settings/assets/tracking.js"]')
;
done_testing;