Index: src/wp-includes/l10n.php
===================================================================
--- src/wp-includes/l10n.php	(revision 44184)
+++ src/wp-includes/l10n.php	(working copy)
@@ -924,8 +924,12 @@
 
 	$obj = $wp_scripts->registered[ $handle ];
 
+	$src = $obj->src;
+	if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $wp_scripts->content_url && 0 === strpos( $src, $wp_scripts->content_url ) ) ) {
+		$src = $wp_scripts->base_url . $src;
+	}
 	/** This filter is documented in wp-includes/class.wp-scripts.php */
-	$src = esc_url( apply_filters( 'script_loader_src', $obj->src, $handle ) );
+	$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
 
 	$relative       = false;
 	$languages_path = WP_LANG_DIR;
@@ -937,10 +941,10 @@
 	// If the host is the same or it's a relative URL.
 	if (
 		strpos( $src_url['path'], $content_url['path'] ) === 0 &&
-		( ! isset( $src_url['host'] ) || $src_url['host'] !== $content_url['host'] )
+		( ! isset( $src_url['host'] ) || $src_url['host'] === $content_url['host'] )
 	) {
 		// Make the src relative the specific plugin or theme.
-		$relative = trim( substr( $src, strlen( $content_url['path'] ) ), '/' );
+		$relative = trim( substr( $src_url['path'], strlen( $content_url['path'] ) ), '/' );
 		$relative = explode( '/', $relative );
 
 		$languages_path = WP_LANG_DIR . '/' . $relative[0];
@@ -947,14 +951,17 @@
 
 		$relative = array_slice( $relative, 2 );
 		$relative = implode( '/', $relative );
-	} elseif ( ! isset( $src_url['host'] ) || $src_url['host'] !== $site_url['host'] ) {
+	} elseif ( ! isset( $src_url['host'] ) || $src_url['host'] === $site_url['host'] ) {
 		if ( ! isset( $site_url['path'] ) ) {
 			$relative = trim( $src_url['path'], '/' );
-		} elseif ( ( strpos( $src_url['path'], $site_url['path'] ) === 0 ) ) {
+		} elseif ( ( strpos( $src_url['path'], trailingslashit( $site_url['path'] ) ) === 0 ) ) {
 			// Make the src relative to the WP root.
-			$relative = substr( $src, strlen( $site_url['path'] ) );
+			$relative = substr( $src_url['path'], strlen( $site_url['path'] ) );
 			$relative = trim( $relative, '/' );
 		}
+	} elseif ( isset( $src_url['host'] ) && $src_url['host'] !== $site_url['host'] && false !== strpos( $src_url['path'], '/wp-includes/' ) ) {
+		// This handles CDNs that mirror all static assets.
+		$relative = substr( $src_url['path'], 1 + strpos( $src_url['path'], '/wp-includes/' ) );
 	}
 
 	// If the source is not from WP.
Index: tests/phpunit/tests/l10n/loadScriptTextdomain.php
===================================================================
--- tests/phpunit/tests/l10n/loadScriptTextdomain.php	(nonexistent)
+++ tests/phpunit/tests/l10n/loadScriptTextdomain.php	(working copy)
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @group l10n
+ * @group i18n
+ */
+class Tests_L10n_loadScriptTextdomain extends WP_UnitTestCase {
+	public function siteurl_example_org() {
+		return 'http://example.org/';
+	}
+
+	public function siteurl_example_org_wp() {
+		return 'http://example.org/wp/';
+	}
+
+	/**
+	 * @ticket 45528
+	 */
+	public function test_resolve_relative_path() {
+		$json_translations = file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' );
+
+		// Test for a WordPress install in root.
+		add_filter( 'pre_option_siteurl', array( $this, 'siteurl_example_org' ) );
+
+		wp_enqueue_script( 'test-example-root', '/wp-includes/js/script.js', array(), null );
+		$this->assertEquals( $json_translations, load_script_textdomain( 'test-example-root', 'default', DIR_TESTDATA . '/languages' ) );
+
+		// Assets on a CDN.
+		wp_enqueue_script( 'test-example-cdn', 'https://c0.wp.com/c/5.0.1/wp-includes/js/script.js', array(), null );
+		$this->assertEquals( $json_translations, load_script_textdomain( 'test-example-cdn', 'default', DIR_TESTDATA . '/languages' ) );
+
+		// Test for WordPress installs in a subdirectory.
+		remove_filter( 'option_get_siteurl', array( $this, 'siteurl_example_org' ) );
+		add_filter( 'pre_option_siteurl', array( $this, 'siteurl_example_org_wp' ) );
+
+		wp_enqueue_script( 'test-example-subdir', '/wp/wp-includes/js/script.js', array(), null );
+		$this->assertEquals( $json_translations, load_script_textdomain( 'test-example-subdir', 'default', DIR_TESTDATA . '/languages' ) );
+
+		// Assets on a CDN.
+		wp_enqueue_script( 'test-example-cdn-subdir', 'https://c0.wp.com/c/5.0.1/wp-includes/js/script.js', array(), null );
+		$this->assertEquals( $json_translations, load_script_textdomain( 'test-example-cdn-subdir', 'default', DIR_TESTDATA . '/languages' ) );
+
+		remove_filter( 'option_get_siteurl', array( $this, 'siteurl_example_org_wp' ) );
+	}
+}
