"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getMediaTypeFromUrl = exports.checkURLValidation = void 0;
var _enums = require("../../social/enums");
var _constants = require("../constants");
const checkURLValidation = url => {
  const pattern = new RegExp('^([a-zA-Z]+:\\/\\/)?' +
  // protocol
  '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
  // domain name
  '((\\d{1,3}\\.){3}\\d{1,3}))' +
  // OR IP (v4) address
  '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
  // port and path
  '(\\?[;&a-z\\d%_.~+=-]*)?' +
  // query string
  '(\\#[-a-z\\d_]*)?$',
  // fragment locator
  'i');
  return pattern.test(url);
};
exports.checkURLValidation = checkURLValidation;
const getMediaTypeFromUrl = url => {
  var _url$split$pop;
  const fileExtension = (_url$split$pop = url.split('.').pop()) === null || _url$split$pop === void 0 ? void 0 : _url$split$pop.toLowerCase();
  if (_constants.ALLOWED_MEDIA_TYPE.image.includes(fileExtension)) return _enums.StoryType.image;
  if (_constants.ALLOWED_MEDIA_TYPE.video.includes(fileExtension)) return _enums.StoryType.video;
  return undefined;
};
exports.getMediaTypeFromUrl = getMediaTypeFromUrl;
//# sourceMappingURL=url.js.map