Skip to content

Commit

Permalink
Fix specific permlink collision on create
Browse files Browse the repository at this point in the history
  • Loading branch information
smoke-indica committed Aug 5, 2020
1 parent c223451 commit 0c09ae0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/redux/TransactionSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ function* createPermlink(title, author, parent_author, parent_permlink) {
if (s === '') {
s = base58.encode(secureRandom.randomBuffer(4))
}
// only letters numbers and dashes shall survive
s = s.toLowerCase().replace(/[^a-z0-9-]+/g, '');
// ensure the permlink(slug) is unique
const slugState = yield call([api, api.getContentAsync], author, s)
let prefix
Expand All @@ -461,16 +463,14 @@ function* createPermlink(title, author, parent_author, parent_permlink) {
permlink = prefix + s
} else {
// comments: re-parentauthor-parentpermlink-time
const timeStr = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '')
const timeStr = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase();
parent_permlink = parent_permlink.replace(/(-\d{8}t\d{9}z)/g, '')
permlink = `re-${parent_author}-${parent_permlink}-${timeStr}`
}
if (permlink.length > 255) {
// SMOKE_MAX_PERMLINK_LENGTH
permlink = permlink.substring(permlink.length - 255, permlink.length)
}
// only letters numbers and dashes shall survive
permlink = permlink.toLowerCase().replace(/[^a-z0-9-]+/g, '')
return permlink
}

Expand Down

0 comments on commit 0c09ae0

Please sign in to comment.