Index: src/wp-admin/includes/misc.php
===================================================================
--- src/wp-admin/includes/misc.php	(revision 34913)
+++ src/wp-admin/includes/misc.php	(working copy)
@@ -271,21 +271,6 @@
 	}
 }
 
-/**
- * Shorten an URL, to be used as link text
- *
- * @since 1.2.0
- *
- * @param string $url
- * @return string
- */
-function url_shorten( $url ) {
-	$short_url = str_replace( array( 'http://', 'www.' ), '', $url );
-	$short_url = untrailingslashit( $short_url );
-	if ( strlen( $short_url ) > 35 )
-		$short_url = substr( $short_url, 0, 32 ) . '&hellip;';
-	return $short_url;
-}
 
 /**
  * Resets global variables based on $_GET and $_POST
Index: src/wp-includes/formatting.php
===================================================================
--- src/wp-includes/formatting.php	(revision 34913)
+++ src/wp-includes/formatting.php	(working copy)
@@ -4693,3 +4693,23 @@
 
 	return $mail;
 }
+
+/** 
+ * Shorten an URL, to be used as link text 
+ * 
+ * @since 1.2.0
+ * @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param
+ * 
+ * @param string $url URL to shorten
+ * @param  int $length Maxiumum length of url to return
+ * @return string 
+*/ 
+function url_shorten( $url, $length = 35 ) { 
+	$short_url = str_replace( array( 'https://', 'http://', 'www.' ), '', $url );
+	$short_url = untrailingslashit( $short_url );
+
+	if ( strlen( $short_url ) > $length ) {
+		$short_url = substr( $short_url, 0, $length - 3 ) . '&hellip;';
+	}
+	return $short_url; 
+} 
\ No newline at end of file
Index: tests/phpunit/tests/formatting/URLShorten.php
===================================================================
--- tests/phpunit/tests/formatting/URLShorten.php	(revision 0)
+++ tests/phpunit/tests/formatting/URLShorten.php	(working copy)
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * @group admin
+ */
+class Tests_Admin_includesMisc extends WP_UnitTestCase {
+	function test_shorten_url() {
+		$tests = array(
+			'wordpress\.org/about/philosophy'
+				=> 'wordpress\.org/about/philosophy', // no longer strips slashes
+			'wordpress.org/about/philosophy'
+				=> 'wordpress.org/about/philosophy',
+			'http://wordpress.org/about/philosophy/'
+				=> 'wordpress.org/about/philosophy', // remove http, trailing slash
+			'http://www.wordpress.org/about/philosophy/'
+				=> 'wordpress.org/about/philosophy', // remove http, www
+			'http://wordpress.org/about/philosophy/#box'
+				=> 'wordpress.org/about/philosophy/#box', // don't shorten 35 characters
+			'http://wordpress.org/about/philosophy/#decisions'
+				=> 'wordpress.org/about/philosophy/#&hellip;', // shorten to 32 if > 35 after cleaning
+		);
+		foreach ( $tests as $k => $v ) {
+			$this->assertEquals( $v, url_shorten( $k ) );
+		}
+
+		$this->assertEquals( 'wordpress.org/about/philosophy/&hellip;', url_shorten( 'http://wordpress.org/about/philosophy/#decisions' ), 31 ); // shorten to 31 if > 34 after cleaning
+	}
+}
