From 0537ad9934f69a680cd20115269efed13e082abf Mon Sep 17 00:00:00 2001
From: Nathan Glasl <nathan@symbiote.com.au>
Date: Tue, 12 Mar 2019 15:52:09 +1100
Subject: [PATCH] [FIX] Links are now formed correctly (#22).

Co-authored-by: nyeholt <marcus@symbiote.com.au>
---
 README.md               | 2 +-
 src/pages/MediaPage.php | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index a4eb5c0..838631c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # [mediawesome](https://packagist.org/packages/nglasl/silverstripe-mediawesome)
 
-_The current release is **4.0.4**_
+_The current release is **4.0.5**_
 
 > This module allows creation of dynamic media holders/pages with CMS customisable types and attributes (blogs, events, news, publications), including versioning.
 
diff --git a/src/pages/MediaPage.php b/src/pages/MediaPage.php
index 8ae3645..cdc7b9c 100644
--- a/src/pages/MediaPage.php
+++ b/src/pages/MediaPage.php
@@ -4,6 +4,7 @@
 
 use SilverStripe\Assets\File;
 use SilverStripe\Assets\Image;
+use SilverStripe\Control\Controller;
 use SilverStripe\Control\HTTPResponse_Exception;
 use SilverStripe\Core\Injector\Injector;
 use SilverStripe\Forms\DateField;
@@ -408,10 +409,14 @@ public function Link($action = null) {
 			return null;
 		}
 		$date = ($parent->URLFormatting !== '-') ? $this->dbObject('Date')->Format($parent->URLFormatting ?: 'y/MM/dd/') : '';
-		$link = $parent->Link() . "{$date}{$this->URLSegment}/";
+		$join = array(
+			$parent->Link(),
+			"{$date}{$this->URLSegment}/"
+		);
 		if($action) {
-			$link .= "{$action}/";
+			$join[] = "{$action}/";
 		}
+		$link = Controller::join_links($join);
 		return $link;
 	}