/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/web/mage/validation/url.js
52 строки
1 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
11 ноя 2025, 17:53
11 ноя 2025, 17:53
f22b64f
Код
Авторство
О чём код?
/** * Copyright 2015 Adobe * All Rights Reserved. */ define([], function () { 'use strict'; return { /** * Redirects to the url if it is considered safe * * @param {String} path - url to be redirected to */ redirect: function (path) { path = this.sanitize(path); if (this.validate(path)) { window.location.href = path; } }, /** * Validates url * * @param {Object} path - url to be validated * @returns {Boolean} */ validate: function (path) { var hostname = window.location.hostname; if (path.indexOf(hostname) === -1 || path.indexOf('javascript:') !== -1 || path.indexOf('vbscript:') !== -1) { return false; } return true; }, /** * Sanitize url, replacing disallowed chars * * @param {String} path - url to be normalized * @returns {String} */ sanitize: function (path) { return path.replace('[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]', ''); } }; });