Skip to content
Permalink
Browse files

Switch to https for build short links

  • Loading branch information...
kzu committed Oct 2, 2019
1 parent 8b0eae5 commit f98570c0296ed8a0a86159b17ed94b9b57610d6a
Showing with 22 additions and 7 deletions.
  1. +17 −2 functions/Build.linq
  2. +4 −4 linkinator/background.js
  3. +1 −1 linkinator/manifest.json
@@ -71,11 +71,26 @@ static IActionResult Run(string org = null, string project = null, double? id =
};

var services = new ServiceCollection().AddLogging(builder => builder.AddConsole());
return Run(request, services.BuildServiceProvider().GetService<ILoggerFactory>().CreateLogger("Console"), org, project, id);

var args = new List<string>();
if (org != null)
args.Add(org);
if (project != null)
args.Add(project);
if (id != null)
args.Add(id.Value.ToString());

return Run(request, services.BuildServiceProvider().GetService<ILoggerFactory>().CreateLogger("Console"), string.Join("/", args));
}

public static IActionResult Run(HttpRequest req, ILogger log, string org = null, string project = null, double? id = null)
public static IActionResult Run(HttpRequest req, ILogger log, string path)
//public static IActionResult Run(HttpRequest req, ILogger log, string org = null, string project = null, double? id = null)
{
var parts = path.Split('/');
var org = parts.FirstOrDefault();
var project = parts.Skip(1).FirstOrDefault();
double? id = parts.Skip(2).Select(x => double.TryParse(x, out var value) ? value : default(double?)).FirstOrDefault();

var parsed = id.HasValue ? id.Value : 0d;

// If the id is omitted, we try to parse it from the org (for DevDiv's super-short
@@ -111,7 +111,7 @@ function shortenUrl(hostname, shortUrl) {
var id = buildId ? parseInt(buildId[1]) : parseInt(definitionId[1]);
var suffix = '';
if (org.toLowerCase() == "devdiv" && project.toLowerCase() == "devdiv")
return 'http://build.azdo.io/' + id;
return 'https://build.azdo.io/' + id;

if (org.toLowerCase() != "devdiv") {
// Match build-azdo function ranges to consider IDs BD or builds.
@@ -121,19 +121,19 @@ function shortenUrl(hostname, shortUrl) {
suffix = '?b';
}

return 'http://build.azdo.io/' + org + '/' + project + '/' + id + suffix;
return 'https://build.azdo.io/' + org + '/' + project + '/' + id + suffix;
}

if (shortUrl.includes('edit-build-definition&id=')) {
var buildId = /id=(\d+)/.exec(shortUrl);
var id = parseInt(buildId[1]);

if (org.toLowerCase() == "devdiv" && project.toLowerCase() == "devdiv") {
return 'http://build.azdo.io/' + id;
return 'https://build.azdo.io/' + id;
} else {
// Match build-azdo function ranges to consider IDs BD or builds.
// A >=200 ID will not be considered a BD by default, so force it in that case.
return 'http://build.azdo.io/' + org + '/' + project + '/' + id + (id >= 200 ? '?d' : '');
return 'https://build.azdo.io/' + org + '/' + project + '/' + id + (id >= 200 ? '?d' : '');
}
}

@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "AzDO Linkinator",
"author": "Daniel Cazzulino",
"version": "0.5.9",
"version": "0.5.10",
"background": {
"scripts": ["background.js"],
"persistent": false

0 comments on commit f98570c

Please sign in to comment.
You can’t perform that action at this time.