Skip to content

Commit

Permalink
fix: add cwrc project id method, fix how cwrc project is identified
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmacdonald committed Oct 2, 2018
1 parent 6c80835 commit df8de29
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ function getProjectLogoRoot() {
return projectLogoRoot
}

let cwrcProjectId = ''
function setCWRCProjectId(id) {
cwrcProjectId = id
}

let projects = {}
function doProjectLookup(url) {
return fetchWithTimeout(url, {credentials: 'same-origin'}).then((parsedJSON)=>{
Expand Down Expand Up @@ -53,17 +58,19 @@ function parseProjectsData(data) {
const und = fieldTopLevel.und
if (und.length > 0 && und[0].pid !== undefined) {
const pid = und[0].pid
const namespace = pid.substring(0, pid.indexOf(':'))
let namespace
if (pid === cwrcProjectId) {
namespace = 'cwrc'
} else {
namespace = pid.substring(0, pid.indexOf(':'))
}
if (namespace !== '') {
projectId = namespace
}
}
}

if (logoFilename !== undefined && projectId !== undefined) {
if (projectId === 'islandora') {
projectId = 'cwrc'
}
if (parsedProjects[projectId] === undefined) {
parsedProjects[projectId] = logoFilename
}
Expand Down Expand Up @@ -176,6 +183,7 @@ module.exports = {

getProjectLogoRoot: getProjectLogoRoot,
setProjectLogoRoot: setProjectLogoRoot,
setCWRCProjectId: setCWRCProjectId,
setProjectLookupURI: doProjectLookup,

findPerson: findPerson,
Expand Down

0 comments on commit df8de29

Please sign in to comment.