Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createHyperLinkIfNeeded(field, object) {
if (typeof field === 'string') {
// a hyperlink
if (field.indexOf('http') === 0) {
return '<a href="' + field + '">' + field + '</a>';
}
if (typeof object === 'object') {
// a file with an extension, discern a link
var metaInstanceId = object['meta.instanceId'];
var formId = object['meta.formId'];
if (typeof metaInstanceId === 'string'
&& typeof formId === 'string'
&& field[field.length - 4] === '.') {
var uuid = metaInstanceId.replace('uuid:', '');
var href = OMK.omkServerUrl() + '/omk/data/submissions/' + formId + '/' + uuid + '/' + field;
return '<a href="' + href + '">' + field + '</a>';
}
}
}
return field;
}