Code Duplication    Length = 10-18 lines in 2 locations

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

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

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

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