Code Duplication    Length = 10-18 lines in 2 locations

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

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

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

@@ 6274-6283 (lines=10) @@
6271
	 * @param string $url
6272
	 * @return WP_Error|string
6273
	 */
6274
	public static function normalize_url_protocol_agnostic( $url ) {
6275
		$parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) );
6276
		if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) {
6277
			return new WP_Error( 'cannot_parse_url', sprintf( esc_html__( 'Cannot parse URL %s', 'jetpack' ), $url ) );
6278
		}
6279
6280
		// Strip www and protocols
6281
		$url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] );
6282
		return $url;
6283
	}
6284
6285
	/**
6286
	 * Gets the value that is to be saved in the jetpack_sync_error_idc option.