Fix double slash in log browsing

The logic for constructing log urls in the manifest component of
the build page was incorrect and would sometimes add a double '/'.
This should produce the correct URLs in all cases.

Change-Id: Idd399d9352215ebdac74b28ff27876ef6907709d
This commit is contained in:
James E. Blair 2019-08-15 13:14:47 -07:00
parent 3aa36dd2d1
commit d68f63c641
1 changed files with 9 additions and 10 deletions

View File

@ -22,33 +22,32 @@ import { Link } from 'react-router-dom'
const renderTree = (tenant, build, path, obj) => {
const node = {}
let name = obj.name
var log_prefix : string
if ('children' in obj && obj.children) {
node.nodes = obj.children.map(n => renderTree(tenant, build, path+'/'+obj.name+'/', n))
node.nodes = obj.children.map(n => renderTree(tenant, build, path+obj.name+'/', n))
}
if (obj.mimetype === 'application/directory') {
name = obj.name + '/'
} else {
node.icon = 'fa fa-file-o'
}
if (path === '') {
log_prefix = '/log/'
} else {
log_prefix = '/log'
let log_url = build.log_url
if (log_url.endsWith('/')) {
log_url = log_url.slice(0, -1)
}
if (obj.mimetype === 'text/plain') {
node.text = (
<span>
<Link to={tenant.linkPrefix + '/build/' + build.uuid + log_prefix + path + name}>{obj.name}</Link>
<Link to={tenant.linkPrefix + '/build/' + build.uuid + '/log' + path + name}>{obj.name}</Link>
&nbsp;&nbsp;
(<a href={build.log_url + path + name}>raw</a>
(<a href={log_url + path + name}>raw</a>
&nbsp;<span className="fa fa-external-link"/>)
</span>)
} else {
node.text = (
<span>
<a href={build.log_url + path + name}>{obj.name}</a>
<a href={log_url + path + name}>{obj.name}</a>
&nbsp;<span className="fa fa-external-link"/>
</span>
)
@ -65,7 +64,7 @@ class Manifest extends React.Component {
render() {
const { tenant, build } = this.props
const nodes = build.manifest.tree.map(n => renderTree(tenant, build, '', n))
const nodes = build.manifest.tree.map(n => renderTree(tenant, build, '/', n))
return (
<React.Fragment>