2 ms·
Truncated URLs may be longer than the original URL if they were just left alone. The URL truncator will append three periods (not a &helip; character) to the e
by jonhohle 16y ago
Truncated URLs may be longer than the original URL if they were just left alone.
The URL truncator will append three periods (not a &helip; character) to the end of a URL. In some cases (say for a URL of 62 characters), the last character will be removed and replaced with three periods. This increases the total size of the URL text to 64 characters.
The algorithm appears to be
def truncate(word, postfix = '...')
if ((word + postfix).length > 64)
word = word[0, 64 - postfix.length] + postfix
end
word
end
There doesn't seem to be a need to add the postfix length to the check. This should suffice:
def truncate(word, postfix = '…')
if (word.length > 64)
word = word[0, 64 - postfix.length] + postfix
end
word
end
- jonhohle 16y agoEdit: Here is an example: http://en.wikipedia.org/wiki/Quartz_Compositor#Quartz_Extreme becomes http://en.wikipedia.org/wiki/Quartz_Compositor#Quartz_Extrem...