Code Duplication    Length = 10-18 lines in 2 locations

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

@@ 6268-6277 (lines=10) @@
6265
	 * @param string $url
6266
	 * @return WP_Error|string
6267
	 */
6268
	public static function normalize_url_protocol_agnostic( $url ) {
6269
		$parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) );
6270
		if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) {
6271
			return new WP_Error( 'cannot_parse_url', sprintf( esc_html__( 'Cannot parse URL %s', 'jetpack' ), $url ) );
6272
		}
6273
6274
		// Strip www and protocols
6275
		$url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] );
6276
		return $url;
6277
	}
6278
6279
	/**
6280
	 * 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

@@ 326-343 (lines=18) @@
323
	 * @return WP_Error|string
324
	 * @since 1.0.0
325
	 */
326
	public static function normalize_url_protocol_agnostic( $url ) {
327
		$parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) );
328
		if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) {
329
			return new WP_Error(
330
				'cannot_parse_url',
331
				sprintf(
332
				/* translators: %s: URL to parse. */
333
					esc_html__( 'Cannot parse URL %s', 'jetpack' ),
334
					$url
335
				)
336
			);
337
		}
338
339
		// Strip www and protocols.
340
		$url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] );
341
342
		return $url;
343
	}
344
345
	/**
346
	 * Gets the value that is to be saved in the jetpack_sync_error_idc option.