Encode/decode tags before using it in the URL

Fixes #994

Conflicts:
	dist/swagger-ui.min.js
This commit is contained in:
Mohsen Azimi
2015-03-17 11:29:59 -07:00
parent f073f192a2
commit 9b409f75b8
5 changed files with 75 additions and 74 deletions

View File

@@ -90,6 +90,7 @@ window.Docs = {
// e.g. /docs/#!/words/get_search
var fragments = $.param.fragment().split('/');
fragments.shift(); // get rid of the bang
fragments = _.map(fragments, decodeURIComponent); // decode encoded paths
switch (fragments.length) {
case 1:
@@ -97,22 +98,22 @@ window.Docs = {
var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
$('[id="' + dom_id + '"]').slideto({highlight: false});
break;
case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search
// Expand Resource
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// $("#"+dom_id).slideto({highlight: false});
// Expand operation
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
Docs.expandOperation($('[id="' + li_content_dom_id + '"]'));
$('[id="' + li_dom_id + '"]').slideto({highlight: false});
break;
}

View File

@@ -18,6 +18,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
this.auths = opts.auths;
this.parentId = this.model.parentId;
this.nickname = this.model.nickname;
this.model.encodedParentId = encodeURIComponent(this.parentId);
return this;
},

View File

@@ -4,15 +4,15 @@
<div class='heading'>
<h3>
<span class='http_method'>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{method}}</a>
<a href='#!/{{encodedParentId}}/{{nickname}}' class="toggleOperation">{{method}}</a>
</span>
<span class='path'>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation {{#if deprecated}}deprecated{{/if}}">{{path}}</a>
<a href='#!/{{encodedParentId}}/{{nickname}}' class="toggleOperation {{#if deprecated}}deprecated{{/if}}">{{path}}</a>
</span>
</h3>
<ul class='options'>
<li>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{{summary}}}</a>
<a href='#!/{{encodedParentId}}/{{nickname}}' class="toggleOperation">{{{summary}}}</a>
</li>
</ul>
</div>