Skip to content

Commit

Permalink
Item13069: make sure the url is well-formed
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Nov 18, 2014
1 parent 72fbb53 commit f330969
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions pub/System/AngularSkin/controller.uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ app.controller("ViewCtrl", [

var match,
path = $location.path(),
url = $location.absUrl().replace(/#.*/, ""),
search = $location.search(),
url = ($location.absUrl()||'').replace(/#.*/, ""),
search = $location.search()||{},
angularMode = search.angular,
web, topic;

Expand All @@ -55,12 +55,19 @@ app.controller("ViewCtrl", [
web = web.replace(/^\/|\/$/g, "");
topic = topic.replace(/^\/|\/$/g, "");


// notify foswiki
foswiki.preferences.WEB = web;
foswiki.preferences.TOPIC = topic;

//$log.debug("parse path=",path,"script=",$scope.script,"web=",web,"topic=",topic);

// make sure the url is well-formed by redirecting to the current location
// this could be the case using short urls and/or on the root location displaying the frontpage without a foswiki url prefix
if (!url) {
$location.url("/"+web+"/"+topic);
}

if (typeof(angularMode) !== 'undefined' && angularMode === "0") {
// reload page
url = foswiki.getScriptUrl("view", web, topic, { angular: 0});
Expand Down
11 changes: 9 additions & 2 deletions pub/System/AngularSkin/pkg.uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ app.controller("ViewCtrl", [

var match,
path = $location.path(),
url = $location.absUrl().replace(/#.*/, ""),
search = $location.search(),
url = ($location.absUrl()||'').replace(/#.*/, ""),
search = $location.search()||{},
angularMode = search.angular,
web, topic;

Expand All @@ -256,12 +256,19 @@ app.controller("ViewCtrl", [
web = web.replace(/^\/|\/$/g, "");
topic = topic.replace(/^\/|\/$/g, "");


// notify foswiki
foswiki.preferences.WEB = web;
foswiki.preferences.TOPIC = topic;

//$log.debug("parse path=",path,"script=",$scope.script,"web=",web,"topic=",topic);

// make sure the url is well-formed by redirecting to the current location
// this could be the case using short urls and/or on the root location displaying the frontpage without a foswiki url prefix
if (!url) {
$location.url("/"+web+"/"+topic);
}

if (typeof(angularMode) !== 'undefined' && angularMode === "0") {
// reload page
url = foswiki.getScriptUrl("view", web, topic, { angular: 0});
Expand Down

0 comments on commit f330969

Please sign in to comment.