Merge pull request #28 from muffinresearch/fireplace-pr409

Uplift from mozilla/fireplace#409
This commit is contained in:
Stuart Colville 2014-05-07 11:33:31 +01:00
Родитель c1c7fb1cfe 4090b1fd26
Коммит 3729b22ba2
3 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@ -21,9 +21,10 @@ define('navigation',
return url; return url;
} }
var used_params = _.pick(utils.querystring(url), settings.param_whitelist);
// We can't use urlparams() because that only extends, not replaces. // We can't use urlparams() because that only extends, not replaces.
return utils.baseurl(url) + '?' + utils.urlencode(used_params); var used_params = _.pick(utils.querystring(url), settings.param_whitelist);
var queryParams = utils.urlencode(used_params);
return utils.baseurl(url) + (queryParams.length ? '?' + queryParams : '');
} }
function canNavigate() { function canNavigate() {
@ -224,7 +225,8 @@ define('navigation',
return { return {
'back': back, 'back': back,
'stack': function() {return stack;}, 'stack': function() {return stack;},
'navigationFilter': navigationFilter 'navigationFilter': navigationFilter,
'extract_nav_url': extract_nav_url
}; };
}); });

Просмотреть файл

@ -19,6 +19,7 @@
<script type="text/javascript" src="/tests/cache.js"></script> <script type="text/javascript" src="/tests/cache.js"></script>
<script type="text/javascript" src="/tests/l10n.js"></script> <script type="text/javascript" src="/tests/l10n.js"></script>
<script type="text/javascript" src="/tests/models.js"></script> <script type="text/javascript" src="/tests/models.js"></script>
<script type="text/javascript" src="/tests/navigation.js"></script>
<script type="text/javascript" src="/tests/requests.js"></script> <script type="text/javascript" src="/tests/requests.js"></script>
<script type="text/javascript" src="/tests/urls.js"></script> <script type="text/javascript" src="/tests/urls.js"></script>
<script type="text/javascript" src="/tests/utils.js"></script> <script type="text/javascript" src="/tests/utils.js"></script>

12
src/tests/navigation.js Normal file
Просмотреть файл

@ -0,0 +1,12 @@
(function() {
var a = require('assert');
var assert = a.assert;
var eq_ = a.eq_;
var navigation = require('navigation');
test('navigation url extraction', function(done) {
eq_(navigation.extract_nav_url('/foo/bar?src=all-popular'), '/foo/bar');
eq_(navigation.extract_nav_url('/foo/bar?src=all-popular&q=bar'), '/foo/bar?q=bar');
done();
});
})();