Code Duplication    Length = 10-18 lines in 2 locations

projects/plugins/jetpack/class.jetpack.php 1 location

@@ 6238-6247 (lines=10) @@
6235
	 * @param string $url
6236
	 * @return WP_Error|string
6237
	 */
6238
	public static function normalize_url_protocol_agnostic( $url ) {
6239
		$parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) );
6240
		if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) {
6241
			return new WP_Error( 'cannot_parse_url', sprintf( esc_html__( 'Cannot parse URL %s', 'jetpack' ), $url ) );
6242
		}
6243
6244
		// Strip www and protocols
6245
		$url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] );
6246
		return $url;
6247
	}
6248
6249
	/**
6250
	 * Gets the value that is to be saved in the jetpack_sync_error_idc option.

projects/packages/identity-crisis/src/class-identity-crisis.php 1 location

@@ 348-365 (lines=18) @@
345
	 * @return WP_Error|string
346
	 * @since 4.4.0
347
	 */
348
	public static function normalize_url_protocol_agnostic( $url ) {
349
		$parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) );
350
		if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) {
351
			return new WP_Error(
352
				'cannot_parse_url',
353
				sprintf(
354
				/* translators: %s: URL to parse. */
355
					esc_html__( 'Cannot parse URL %s', 'jetpack' ),
356
					$url
357
				)
358
			);
359
		}
360
361
		// Strip www and protocols.
362
		$url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] );
363
364
		return $url;
365
	}
366
367
	/**
368
	 * Gets the value that is to be saved in the jetpack_sync_error_idc option.