From 0c09ae0dd2d14308d5c390016e54a2258638cee9 Mon Sep 17 00:00:00 2001 From: indica Date: Wed, 5 Aug 2020 17:16:47 +0100 Subject: [PATCH] Fix specific permlink collision on create https://github.com/steemit/condenser/pull/3286 https://github.com/steemit/condenser/pull/3303 --- src/app/redux/TransactionSaga.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/redux/TransactionSaga.js b/src/app/redux/TransactionSaga.js index 9b186fa..10179f5 100644 --- a/src/app/redux/TransactionSaga.js +++ b/src/app/redux/TransactionSaga.js @@ -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 @@ -461,7 +463,7 @@ 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}` } @@ -469,8 +471,6 @@ function* createPermlink(title, author, parent_author, parent_permlink) { // 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 }