{"id":458517,"date":"2025-05-04T15:00:05","date_gmt":"2025-05-04T15:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=458517"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=458517","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u0441 JavaScript?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438\u043b\u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u043e\u0431\u0434\u0443\u043c\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0445\u0430\u043b\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435.<\/p>\n<p>\u042f \u0445\u043e\u0447\u0443 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<ol>\n<li>\n<p><code>window.location.href<\/code><\/p>\n<\/li>\n<li>\n<p><code>window.location.assign<\/code><\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0445\u043e\u0434\u0441\u0442\u0432\u0430<\/h3>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e: \u043e\u0431\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043e\u0431\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u044b XSS-\u0430\u0442\u0430\u043a\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442:<\/p>\n<pre><code class=\"javascript\">const input = 'javascript:alert(\"\u0445\u0430\u043a\")';  window.location.href = input; window.location.assign(input);<\/code><\/pre>\n<h3>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f<\/h3>\n<p><strong>\u0413\u043b\u0430\u0432\u043d\u043e\u0435<\/strong> \u2014 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e window.location.href = '&lt;https:\/\/example.com&gt;';  \/\/ \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 window.location.assign('&lt;https:\/\/example.com&gt;');<\/code><\/pre>\n<p><strong>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438<\/strong><\/p>\n<p><code>href<\/code> \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438 \u0441 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u043d\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439.<\/p>\n<p><code>assign<\/code> \u043f\u043e\u043f\u0430\u043b \u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 W3C \u043e\u0441\u0435\u043d\u044c\u044e 2014 \u0433\u043e\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0441 \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u043d \u0431\u044b\u043b \u0432\u0435\u0437\u0434\u0435.<\/p>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>assign()<\/code> \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"typescript\">\/\/ Jest \u043f\u0440\u0438\u043c\u0435\u0440 const mockAssign = jest.fn(); window.location.assign = mockAssign;  \/\/ \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 expect(mockAssign)   .toHaveBeenCalledWith('&lt;https:\/\/valid-url.com&gt;');<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code><strong>href<\/strong><\/code> \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043c\u043e\u043a\u0438\u043d\u0433 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u0441\u0447\u0438\u0442\u0430\u044e location.assign \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u0443\u0447\u0448\u0435?<\/h3>\n<ol>\n<li>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442.  \u0421 <code><strong>href<\/strong><\/code> \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0431\u0438\u0432\u0430\u0442\u044c \u0441 \u0442\u043e\u043b\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c \u2014 \u201c\u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u201d. \u0412 \u0446\u0435\u043b\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0447\u0438\u0449\u0435.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u0438 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0435?<\/h3>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 URL \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"typescript\">function safeRedirect(href: string) {   try {     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c URL-\u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 href     const urlObject = new URL(       href,       \/\/ \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 URL \u043d\u0435 \u043b\u043e\u043c\u0430\u043b\u0438\u0441\u044c       window.location.origin,      );     \/\/ \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c     window.location.assign(urlObject);   } catch (error) {     console.error('\u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 URL:', href, error);     return error;   } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u044d\u0442\u043e URL (\u043f\u043e\u043b\u043d\u044b\u0439 \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e search params \u0438\u043b\u0438 hash) \u0438 \u043d\u0435 \u0434\u0430\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<pre><code class=\"typescript\">type SafeRedirectOptions = {   \/**    * \u0415\u0441\u043b\u0438 true, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430.    * @default true    *\/   history?: boolean; };  const defaultSafeRedirectOptions: SafeRedirectOptions = { history: true };  \/**  * \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 URL.  *  * @param url \u0421\u0442\u0440\u043e\u043a\u0430 URL \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c (\u0430 \u0442\u0430\u043a \u0436\u0435 query, hash).  * @throws {TypeError} \u0415\u0441\u043b\u0438 URL \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d.  * @example  * safeRedirect('&lt;https:\/\/example.com&gt;');  * safeRedirect('\/path\/to\/page');  * safeRedirect('javascript:alert(\"\u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044e\u0441\u044c..\")')  *   .catch((error) =&gt; console.error('\u0417\u0430\u0442\u043e \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f!', error));  *\/ export function safeRedirect(url: string, optionsArg: SafeRedirectOptions = defaultSafeRedirectOptions): Promise&lt;void&gt; {   const options = { ...defaultSafeRedirectOptions, ...optionsArg };    return new Promise((resolve, reject) =&gt; {     try {       window.location[options.history ? 'assign' : 'replace'](new URL(url, window.location.origin));       resolve();     } catch (error) {       console.error('[safeRedirect] \u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 URL:', url, error);       reject(new TypeError(`Invalid URL provided: ${url}`));     }   }); }<\/code><\/pre>\n<h3>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0430<\/h3>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>href<\/code> \u0438\u043b\u0438 <code>assign<\/code> \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u044c\u0435\u043c\u0441\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430. \u0422.\u0435. \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0438\u0436\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0431\u0443\u0434\u0442\u043e <code>href<\/code> \u0438\u043b\u0438 <code>assign<\/code> \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e:<\/p>\n<pre><code class=\"typescript\">window.location.href = '&lt;https:\/\/maxxborer.com&gt;'; alert('\u042f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \ud83e\udd14');  window.location.assign('&lt;https:\/\/maxxborer.com&gt;'); alert('\u0418 \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \ud83e\udee0');<\/code><\/pre>\n<p>\u041d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0442 \u0436\u0435 <code>assign<\/code> \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Promise \u0438 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u0436\u0435 <code>await<\/code>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0430 \u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0430\u0436\u043d\u043e? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0430\u0448\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0443\u0447\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e. \u0421\u0435\u0441\u0441\u0438\u044f \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u0438 \u0432\u0430\u043c, \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f 401 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442, \u043d\u043e \u0447\u0442\u043e \u0442\u043e\u043b\u043a\u0443? \u0412\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u0430\u043a \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043d\u0435 \u0434\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0438\u0441\u0443 \u0437\u0430\u0440\u0435\u0437\u043e\u043b\u0432\u0438\u0442\u044c\u0441\u044f:<\/p>\n<pre><code class=\"typescript\">\/**  * \u0417\u0430\u043c\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.  * @param ms \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.  * @returns Promise&lt;void&gt;  *\/ const sleep = (ms: number) =&gt; new Promise((resolve) =&gt; setTimeout(resolve, ms));  type SafeRedirectOptions = {   \/**    * \u0415\u0441\u043b\u0438 true, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430.    * @default true    *\/   history?: boolean;   \/**    * \u0415\u0441\u043b\u0438 true, \u0442\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d (\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f `await`).    * @default false    *\/   freeze?: boolean; };  const defaultSafeRedirectOptions: SafeRedirectOptions = { history: true, freeze: false }; \/\/ \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0437\u0430 5 \u0441\u0435\u043a\u0443\u043d\u0434 \u0443\u0441\u043f\u0435\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 const SLEEP_TIME_FREEZE = 5000;  \/**  * \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 URL.  *  * @param url \u0421\u0442\u0440\u043e\u043a\u0430 URL \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c (\u0430 \u0442\u0430\u043a \u0436\u0435 query, hash).  * @throws {TypeError} \u0415\u0441\u043b\u0438 URL \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d.  * @example  * safeRedirect('&lt;https:\/\/example.com&gt;');  * safeRedirect('\/path\/to\/page');  * safeRedirect('javascript:alert(\"\u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044e\u0441\u044c..\")')  *   .catch((error) =&gt; console.error('\u0417\u0430\u0442\u043e \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f!', error));  * await safeRedirect('&lt;https:\/\/example.com&gt;', { freeze: true }); \/\/ \u0437\u0430\u043c\u043e\u0440\u043e\u0437\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f  *\/ export function safeRedirect(url: string, optionsArg: SafeRedirectOptions = defaultSafeRedirectOptions): Promise&lt;void&gt; {   const options = { ...defaultSafeRedirectOptions, ...optionsArg };    return new Promise((resolve, reject) =&gt; {     try {       window.location[options.history ? 'assign' : 'replace'](new URL(url, window.location.origin));        if (options.freeze) {         \/\/ \u0412 \u0446\u0435\u043b\u043e\u043c \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c resolve \u0437\u0434\u0435\u0441\u044c,         \/\/ \u043d\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b         \/\/ \u043a \u0443\u0442\u0435\u0447\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438         sleep(SLEEP_TIME_FREEZE).then(() =&gt; resolve());       } else {         resolve();       }     } catch (error) {       console.error('[safeRedirect] \u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 URL:', url, error);       reject(new TypeError(`Invalid URL provided: ${url}`));     }   }); }<\/code><\/pre>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<pre><code class=\"typescript\">async function onError(status: number) {   if (status === 401) {     \/\/ \u043f\u0440\u043e\u043c\u0438\u0441 \u043d\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0438\u0442\u0441\u044f, \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f     await safeRedirect('\/login', { freeze: true });     return;   }   \/\/ \u0434\u0440\u0443\u0433\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a }<\/code><\/pre>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 <code>window.location.href<\/code> \u0438 <code>window.location.assign()<\/code> \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u044b: \u043e\u0431\u0430 \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0436\u043d\u0430 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <code>href<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0447\u0438\u0441\u0442\u044b\u0439, \u044f\u0432\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u2014 \u043e\u0442\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 <code>location.assign()<\/code>.<\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e URL \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/906744\/\"> https:\/\/habr.com\/ru\/articles\/906744\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438\u043b\u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u043e\u0431\u0434\u0443\u043c\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0445\u0430\u043b\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435.<\/p>\n<p>\u042f \u0445\u043e\u0447\u0443 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<ol>\n<li>\n<p><code>window.location.href<\/code><\/p>\n<\/li>\n<li>\n<p><code>window.location.assign<\/code><\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0445\u043e\u0434\u0441\u0442\u0432\u0430<\/h3>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e: \u043e\u0431\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043e\u0431\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u044b XSS-\u0430\u0442\u0430\u043a\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442:<\/p>\n<pre><code class=\"javascript\">const input = 'javascript:alert(\"\u0445\u0430\u043a\")';  window.location.href = input; window.location.assign(input);<\/code><\/pre>\n<h3>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f<\/h3>\n<p><strong>\u0413\u043b\u0430\u0432\u043d\u043e\u0435<\/strong> \u2014 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e window.location.href = '&lt;https:\/\/example.com&gt;';  \/\/ \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 window.location.assign('&lt;https:\/\/example.com&gt;');<\/code><\/pre>\n<p><strong>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438<\/strong><\/p>\n<p><code>href<\/code> \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438 \u0441 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u043d\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439.<\/p>\n<p><code>assign<\/code> \u043f\u043e\u043f\u0430\u043b \u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 W3C \u043e\u0441\u0435\u043d\u044c\u044e 2014 \u0433\u043e\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0441 \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u043d \u0431\u044b\u043b \u0432\u0435\u0437\u0434\u0435.<\/p>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>assign()<\/code> \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"typescript\">\/\/ Jest \u043f\u0440\u0438\u043c\u0435\u0440 const mockAssign = jest.fn(); window.location.assign = mockAssign;  \/\/ \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 expect(mockAssign)   .toHaveBeenCalledWith('&lt;https:\/\/valid-url.com&gt;');<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code><strong>href<\/strong><\/code> \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043c\u043e\u043a\u0438\u043d\u0433 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u0441\u0447\u0438\u0442\u0430\u044e location.assign \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u0443\u0447\u0448\u0435?<\/h3>\n<ol>\n<li>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442.  \u0421 <code><strong>href<\/strong><\/code> \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0431\u0438\u0432\u0430\u0442\u044c \u0441 \u0442\u043e\u043b\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c \u2014 \u201c\u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u201d. \u0412 \u0446\u0435\u043b\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0447\u0438\u0449\u0435.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u0438 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0435?<\/h3>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 URL \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"typescript\">function safeRedirect(href: string) {   try {     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c URL-\u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 href     const urlObject = new URL(       href,       \/\/ \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 URL \u043d\u0435 \u043b\u043e\u043c\u0430\u043b\u0438\u0441\u044c       window.location.origin,      );     \/\/ \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c     window.location.assign(urlObject);   } catch (error) {     console.error('\u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 URL:', href, error);     return error;   } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u044d\u0442\u043e URL (\u043f\u043e\u043b\u043d\u044b\u0439 \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e search params \u0438\u043b\u0438 hash) \u0438 \u043d\u0435 \u0434\u0430\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<pre><code class=\"typescript\">type SafeRedirectOptions = {   \/**    * \u0415\u0441\u043b\u0438 true, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430.    * @default true    *\/   history?: boolean; };  const defaultSafeRedirectOptions: SafeRedirectOptions = { history: true };  \/**  * \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 URL.  *  * @param url \u0421\u0442\u0440\u043e\u043a\u0430 URL \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c (\u0430 \u0442\u0430\u043a \u0436\u0435 query, hash).  * @throws {TypeError} \u0415\u0441\u043b\u0438 URL \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d.  * @example  * safeRedirect('&lt;https:\/\/example.com&gt;');  * safeRedirect('\/path\/to\/page');  * safeRedirect('javascript:alert(\"\u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044e\u0441\u044c..\")')  *   .catch((error) =&gt; console.error('\u0417\u0430\u0442\u043e \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f!', error));  *\/ export function safeRedirect(url: string, optionsArg: SafeRedirectOptions = defaultSafeRedirectOptions): Promise&lt;void&gt; {   const options = { ...defaultSafeRedirectOptions, ...optionsArg };    return new Promise((resolve, reject) =&gt; {     try {       window.location[options.history ? 'assign' : 'replace'](new URL(url, window.location.origin));       resolve();     } catch (error) {       console.error('[safeRedirect] \u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 URL:', url, error);       reject(new TypeError(`Invalid URL provided: ${url}`));     }   }); }<\/code><\/pre>\n<h3>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0430<\/h3>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>href<\/code> \u0438\u043b\u0438 <code>assign<\/code> \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u044c\u0435\u043c\u0441\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430. \u0422.\u0435. \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0438\u0436\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0431\u0443\u0434\u0442\u043e <code>href<\/code> \u0438\u043b\u0438 <code>assign<\/code> \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e:<\/p>\n<pre><code class=\"typescript\">window.location.href = '&lt;https:\/\/maxxborer.com&gt;'; alert('\u042f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \ud83e\udd14');  window.location.assign('&lt;https:\/\/maxxborer.com&gt;'); alert('\u0418 \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \ud83e\udee0');<\/code><\/pre>\n<p>\u041d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0442 \u0436\u0435 <code>assign<\/code> \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Promise \u0438 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u0436\u0435 <code>await<\/code>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0430 \u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0430\u0436\u043d\u043e? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0430\u0448\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0443\u0447\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e. \u0421\u0435\u0441\u0441\u0438\u044f \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u0438 \u0432\u0430\u043c, \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f 401 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442, \u043d\u043e \u0447\u0442\u043e \u0442\u043e\u043b\u043a\u0443? \u0412\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u0430\u043a \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043d\u0435 \u0434\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0438\u0441\u0443 \u0437\u0430\u0440\u0435\u0437\u043e\u043b\u0432\u0438\u0442\u044c\u0441\u044f:<\/p>\n<pre><code class=\"typescript\">\/**  * \u0417\u0430\u043c\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.  * @param ms \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.  * @returns Promise&lt;void&gt;  *\/ const sleep = (ms: number) =&gt; new Promise((resolve) =&gt; setTimeout(resolve, ms));  type SafeRedirectOptions = {   \/**    * \u0415\u0441\u043b\u0438 true, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430.    * @default true    *\/   history?: boolean;   \/**    * \u0415\u0441\u043b\u0438 true, \u0442\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d (\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f `await`).    * @default false    *\/   freeze?: boolean; };  const defaultSafeRedirectOptions: SafeRedirectOptions = { history: true, freeze: false }; \/\/ \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0437\u0430 5 \u0441\u0435\u043a\u0443\u043d\u0434 \u0443\u0441\u043f\u0435\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 const SLEEP_TIME_FREEZE = 5000;  \/**  * \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 URL.  *  * @param url \u0421\u0442\u0440\u043e\u043a\u0430 URL \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c (\u0430 \u0442\u0430\u043a \u0436\u0435 query, hash).  * @throws {TypeError} \u0415\u0441\u043b\u0438 URL \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d.  * @example  * safeRedirect('&lt;https:\/\/example.com&gt;');  * safeRedirect('\/path\/to\/page');  * safeRedirect('javascript:alert(\"\u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044e\u0441\u044c..\")')  *   .catch((error) =&gt; console.error('\u0417\u0430\u0442\u043e \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f!', error));  * await safeRedirect('&lt;https:\/\/example.com&gt;', { freeze: true }); \/\/ \u0437\u0430\u043c\u043e\u0440\u043e\u0437\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f  *\/ export function safeRedirect(url: string, optionsArg: SafeRedirectOptions = defaultSafeRedirectOptions): Promise&lt;void&gt; {   const options = { ...defaultSafeRedirectOptions, ...optionsArg };    return new Promise((resolve, reject) =&gt; {     try {       window.location[options.history ? 'assign' : 'replace'](new URL(url, window.location.origin));        if (options.freeze) {         \/\/ \u0412 \u0446\u0435\u043b\u043e\u043c \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c resolve \u0437\u0434\u0435\u0441\u044c,         \/\/ \u043d\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b         \/\/ \u043a \u0443\u0442\u0435\u0447\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438         sleep(SLEEP_TIME_FREEZE).then(() =&gt; resolve());       } else {         resolve();       }     } catch (error) {       console.error('[safeRedirect] \u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 URL:', url, error);       reject(new TypeError(`Invalid URL provided: ${url}`));     }   }); }<\/code><\/pre>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<pre><code class=\"typescript\">async function onError(status: number) {   if (status === 401) {     \/\/ \u043f\u0440\u043e\u043c\u0438\u0441 \u043d\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0438\u0442\u0441\u044f, \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f     await safeRedirect('\/login', { freeze: true });     return;   }   \/\/ \u0434\u0440\u0443\u0433\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a }<\/code><\/pre>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 <code>window.location.href<\/code> \u0438 <code>window.location.assign()<\/code> \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u044b: \u043e\u0431\u0430 \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0436\u043d\u0430 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <code>href<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0447\u0438\u0441\u0442\u044b\u0439, \u044f\u0432\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u2014 \u043e\u0442\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 <code>location.assign()<\/code>.<\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e URL \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/906744\/\"> https:\/\/habr.com\/ru\/articles\/906744\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-458517","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/458517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=458517"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/458517\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=458517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=458517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=458517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}