Skip to content

Commit

Permalink
ucfopen#17 Use UUIDs instead of an incrementing number for new IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrenjaminBanklin committed Jan 28, 2019
1 parent 20f64be commit 7a61f7b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions express.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const yaml = require('yamljs');
const { execSync } = require('child_process');
const waitUntil = require('wait-until-promise').default
const hoganExpress = require('hogan-express')
const uuid = require('uuid')

var webPackMiddleware = false;
var hasCompiled = false;
Expand Down Expand Up @@ -97,10 +98,8 @@ var performQSetSubsitutions = (qset) => {
qset = qset.replace(/"<%MEDIA='(.+?)'%>"/g, '"__$1__"')

// look for "id": null or "id": 0 or "id": "" and build a mock id
let id = 0
qset = qset.replace(/("id"\s?:\s?)(null|0|"")/g, function(match, offset, string){
id++
return `"id": "mwdk-mock-id-${id}"`
return `"id": "mwdk-mock-id-${uuid()}"`
})

return JSON.parse(qset)
Expand Down

0 comments on commit 7a61f7b

Please sign in to comment.