File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,15 @@ module.exports = steemAPI => {
183
183
. replace ( / [ ^ a - z A - Z 0 - 9 ] + / g, "" )
184
184
. toLowerCase ( ) ;
185
185
parentPermlink = parentPermlink . replace ( / ( - \d { 8 } t \d { 9 } z ) / g, "" ) ;
186
- return "re-" + parentAuthor + "-" + parentPermlink + "-" + timeStr ;
186
+ let permLink =
187
+ "re-" + parentAuthor + "-" + parentPermlink + "-" + timeStr ;
188
+ if ( permLink . length > 255 ) {
189
+ // pay respect to STEEMIT_MAX_PERMLINK_LENGTH
190
+ permLink . substr ( permLink . length - 255 , permLink . length ) ;
191
+ }
192
+ // permlinks must be lower case and not contain anything but
193
+ // alphanumeric characters plus dashes
194
+ return permLink . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 - ] + / g, "" ) ;
187
195
} ,
188
196
189
197
amount : function ( amount , asset ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import Promise from 'bluebird';
2
2
import should from 'should' ;
3
3
import steem from '../src' ;
4
4
import pkg from '../package.json' ;
5
+ import assert from 'assert'
5
6
6
7
const username = process . env . STEEM_USERNAME || 'guest123' ;
7
8
const password = process . env . STEEM_PASSWORD ;
@@ -67,3 +68,14 @@ describe('steem.broadcast:', () => {
67
68
} ) ;
68
69
} ) ;
69
70
} ) ;
71
+
72
+ describe ( 'commentPermLink:' , ( ) => {
73
+ it ( 'does not return dots' , ( ) => {
74
+ var commentPermlink = steem . formatter . commentPermlink (
75
+ 'foo.bar' ,
76
+ 'the-first-physical-foo-bar-ready-to-be-shipped'
77
+ ) ;
78
+ console . log ( commentPermlink ) ;
79
+ assert . equal ( - 1 , commentPermlink . indexOf ( '.' ) ) ;
80
+ } ) ;
81
+ } ) ;
You can’t perform that action at this time.
0 commit comments