/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/webpack-dev-server/client/utils/getCurrentScriptSource.js
24 строки
868 B
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
/** * @returns {string} */ function getCurrentScriptSource() { // `document.currentScript` is the most accurate way to find the current script, // but is not supported in all browsers. if (document.currentScript) { return document.currentScript.getAttribute("src"); } // Fallback to getting all scripts running in the document. var scriptElements = document.scripts || []; var scriptElementsWithSrc = Array.prototype.filter.call(scriptElements, function (element) { return element.getAttribute("src"); }); if (scriptElementsWithSrc.length > 0) { var currentScript = scriptElementsWithSrc[scriptElementsWithSrc.length - 1]; return currentScript.getAttribute("src"); } // Fail as there was no script to use. throw new Error("[webpack-dev-server] Failed to get current script source."); } export default getCurrentScriptSource;