dom_is-file-link.js

/**
 * @module isFileUrl
 * @description Tests if an url ends with a section that contains a "." and inferring it to be a file.
 * This obviously won't work with a file that has some sort of shortening/obfuscation to it.
 *
 * @since 1.0.0
 *
 * @param {string} url The url to test.
 *
 * @return {boolean} Whether the passed string is a file url or not.
 *
 * @example
 * import { isFileUrl } from "@gravityforms/utils";
 *
 * function Example() {
 *   const url = 'https://some-url.com/hello.jpg';
 *   if ( isFileUrl( url ) ) {
 *       // do something
 *   }
 * }
 *
 */
export default function isFileUrl( url = '' ) {
	const ext = url.split( '/' ).pop();
	return ext.indexOf( '.' ) !== -1;
}