Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 38262)
+++ src/wp-includes/media.php	(working copy)
@@ -2463,9 +2463,10 @@
 	$primary = false;
 	if ( ! empty( $atts['src'] ) ) {
 		$is_vimeo = ( preg_match( $vimeo_pattern, $atts['src'] ) );
-		$is_youtube = (  preg_match( $yt_pattern, $atts['src'] ) );
+		$is_youtube = ( preg_match( $yt_pattern, $atts['src'] ) );
 		if ( ! $is_youtube && ! $is_vimeo ) {
-			$type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
+			$filename = basename( parse_url( $atts['src'], PHP_URL_PATH ) );
+			$type = wp_check_filetype( $filename, wp_get_mime_types() );
 			if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
 				return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) );
 			}
@@ -2480,7 +2481,8 @@
 	} else {
 		foreach ( $default_types as $ext ) {
 			if ( ! empty( $atts[ $ext ] ) ) {
-				$type = wp_check_filetype( $atts[ $ext ], wp_get_mime_types() );
+				$filename = basename( parse_url( $atts[ $ext ], PHP_URL_PATH ) );
+				$type = wp_check_filetype( $filename, wp_get_mime_types() );
 				if ( strtolower( $type['ext'] ) === $ext ) {
 					$primary = true;
 				}
