Skip to content

Commit 6aff985

Browse files
committed
Hyperlink the URLs in the Link (RFC 5988) header.
1 parent aa23360 commit 6aff985

File tree

4 files changed

+135
-85
lines changed

4 files changed

+135
-85
lines changed

chrome/js/modules/layout.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ pm.layout = {
264264
pm.request.loadRequestFromLink(link, headers);
265265
});
266266

267+
$('#response-headers').on("mousedown", ".cm-link", function () {
268+
var link = $(this).text();
269+
var headers = $('#headers-keyvaleditor').keyvalueeditor('getValues');
270+
pm.request.loadRequestFromLink(link, headers);
271+
});
272+
267273
$('.response-tabs').on("click", "li", function () {
268274
var section = $(this).attr('data-section');
269275
if (section === "body") {
@@ -285,6 +291,21 @@ pm.layout = {
285291
$('.request-meta-actions').css("display", "none");
286292
});
287293

294+
var linkRegex = /(\s*<\s*)([^>]*)(\s*>[^,]*,?)/g;
295+
296+
var linkFunc = function (all, pre_uri, uri, post_uri) {
297+
return Handlebars.Utils.escapeExpression(pre_uri)
298+
+ "<span class=\"cm-link\">"
299+
+ uri
300+
+ "</span>"
301+
+ Handlebars.Utils.escapeExpression(post_uri);
302+
};
303+
304+
Handlebars.registerHelper('link_to_hyperlink', function(linkValue) {
305+
var output = linkValue.replace(linkRegex, linkFunc);
306+
return new Handlebars.SafeString(output);
307+
});
308+
288309
this.attachModalHandlers();
289310
this.setLayout();
290311
},

chrome/js/modules/request.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,10 @@ pm.request = {
14701470
"description":headerDetails[name.toLowerCase()]
14711471
};
14721472

1473+
if (name.toLowerCase() === "link") {
1474+
header.isLink = true;
1475+
}
1476+
14731477
vars.push(header);
14741478
}
14751479
}

0 commit comments

Comments
 (0)