lighthouse-plugin-publisher-ads/utils/resource-classification.js
/**
 * Converts the given url to a URL, if it's not already a URL. Otherwise returns
 * the same URL object (not a copy).
 * This function is guaranteed not to throw. Be sure to validate URL format
 * before calling this method if needed.
 * @param {URL|string} urlOrStr
 * @return {URL}
 */
Converts the given url to a URL, if it's not already a URL. Otherwise returns
the same URL object (not a copy).
This function is guaranteed not to throw. Be sure to validate URL format
before calling this method if needed.
@param {URL|string} urlOrStr
@return {URL}
Converts the given url to a URL if it ' s not already a URL . Otherwise returns the same URL object ( not a copy ) . This function is guaranteed not to throw . Be sure to validate URL format before calling this method if needed . @param { URL|string } urlOrStr @return { URL }
function toURL(urlOrStr) {
  let url;
  try {
    url = (typeof urlOrStr === 'string') ? new URL(urlOrStr) : urlOrStr;
  } catch (e) {
    url = new URL('http://_'); 
  }
  return url;
}
function toURL ( urlOrStr ) { let url ; try { url = ( typeof urlOrStr === 'string' ) ? new URL ( urlOrStr ) : urlOrStr ; } catch ( e ) { url = new URL ( 'http://_' ) ; } return url ; }
Converts the given url to a URL, if it's not already a URL.
Converts the given url to a URL if it ' s not already a URL .
// error