Kaydet (Commit) 7c4f05fa authored tarafından monotonee's avatar monotonee Kaydeden (comit) Tim Graham

Fixed #28295 -- Made admin's URLify.js trim trailing hyphens.

üst 68812ba8
......@@ -172,8 +172,9 @@
}
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
s = s.toLowerCase(); // convert to lowercase
return s.substring(0, num_chars); // trim to first num_chars chars
s = s.substring(0, num_chars); // trim to first num_chars chars
s = s.replace(/-+$/g, ''); // trim any trailing hyphens
return s.toLowerCase(); // convert to lowercase
}
window.URLify = URLify;
})();
......@@ -19,3 +19,7 @@ QUnit.test('strip non-URL characters', function(assert) {
QUnit.test('merge adjacent whitespace', function(assert) {
assert.strictEqual(URLify('D silent', 8, true), 'd-silent');
});
QUnit.test('trim trailing hyphens', function(assert) {
assert.strictEqual(URLify('D silent always', 9, true), 'd-silent');
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment