{"id":299228,"date":"2020-02-25T15:00:16","date_gmt":"2020-02-25T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299228"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-02-25T15:00:16","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299228","title":{"rendered":"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f URL \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043d\u0430 \u043a\u043e\u043b\u0435\u043d\u043a\u0435 \u0438 best practice"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489888\/\">\n<p>\u041a\u0430\u043a-\u0442\u043e \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 URL-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 <code>iframe<\/code> src-\u0430\u0442\u0440\u0438\u0431\u0443\u0442.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u0448\u043d\u0435\u0439, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439 \u0438\u043b\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0440\u0430\u0437 \u0442\u0430\u043a\u043e\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0436\u0438\u0432\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u0435, \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043c\u043e\u043b\u0447\u0430\u0442\u044c, \u0430 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f best-practices.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043e\u043d, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const createQueryString = (param1, param2, objectId, timestamp, name) =&gt; {   const encodedTimestamp = encodeURIComponent(timestamp);   const delimiter = '&amp;';   const queryString = `${param1}${delimiter}         param2=${param2}${delimiter}         objectId=${objectId}${delimiter}         itemTimestamp=${encodedTimestamp}${delimiter}         itemName=${name}`;   return queryString.replace(\/ \/g, '%20'); };<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0414\u043b\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0438, <code>param1<\/code> \u0438 <code>param2<\/code> \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0438\u043c\u0435\u044e\u0442 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u0410 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0434\u043b\u044f URL \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<\/em><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"kakie-problemy-u-etogo-koda\">\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430?<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 <code>encodeURIComponent<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043b\u044e\u0431\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u043a\u0438 \u0432\u0440\u043e\u0434\u0435 \u0430\u043c\u043f\u0435\u0440\u0441\u0430\u043d\u0434\u0430, \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0438\u043b\u0438 \u0434\u0438\u0430\u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432);<\/li>\n<li>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Template_literals\">\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/a> template string <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Template_literals\"><code>`<\/code><\/a>; \u0418\u0445 \u0430\u0432\u0442\u043e\u0440 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>.replace()<\/code>, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442;<\/li>\n<li>\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u044d\u0442\u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0438 \u043d\u0435\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437-\u0437\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u0448\u0438\u0431\u043a\u0430\u043c.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"kak-ih-ispravit\">\u041a\u0430\u043a \u0438\u0445 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c?<\/h2>\n<p>  <\/p>\n<h4 id=\"pervyy-podhod\">\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">const delimiter = '&amp;'; \/\/ \u0432\u044b\u043d\u043e\u0441\u0438\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 const createQueryString = (param1, param2, objectId, timestamp, name) =&gt; {   const queryString = [     `param1=${encodeURIComponent(param1)}`,     `param2=${encodeURIComponent(param2)}`,     `objectId=${encodeURIComponent(objectId)}`,     `itemTimestamp=${encodeURIComponent(timestamp)}`,     `itemName=${encodeURIComponent(name)}`   ].join(delimeter);   return queryString; };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c \u0437\u0434\u0435\u0441\u044c? \u041a\u043e\u0434 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041b\u0438\u0448\u043d\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0442, \u0430 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>encodeURIComponent<\/code>. \u0410 \u0435\u0449\u0435 \u0432\u044b\u043d\u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u043d\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u0430\u043a \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041a\u043e\u0434 \u0441\u0442\u0430\u043b \u0447\u0443\u0442\u043e\u0447\u043a\u0443 \u0447\u0438\u0449\u0435.<\/p>\n<p>  <\/p>\n<h4 id=\"mozhno-luchshe-mozhno-vtoroy-podhod\">\u041c\u043e\u0436\u043d\u043e \u043b\u0443\u0447\u0448\u0435? \u041c\u043e\u0436\u043d\u043e! \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">const createQueryString = (param1, param2, objectId, timestamp, name) =&gt; {   const queryParams = {      param1,      param2,      objectId,      itemTimestamp: timestamp,      itemName: name   };   const encodeAndJoinPair = pair =&gt; pair.map(encodeURIComponent).join('=');   return Object.entries(queryParams).map(encodeAndJoinPair).join('&amp;'); };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u0430\u043c\u043e\u043b\u044c\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u2014 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430. <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0442\u0440\u043e\u043a, \u0440\u0443\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0439. \u0417\u0430\u043e\u0434\u043d\u043e \u043c\u044b \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u0438 \u043a\u043b\u044e\u0447\u0430.<\/p>\n<p>  <\/p>\n<h5 id=\"i-esche-razok\">\u0418 \u0435\u0449\u0435 \u0440\u0430\u0437\u043e\u043a<\/h5>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0435\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432? \u041d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>queryParams<\/code>. \u0410 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u044d\u0442\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u043d\u043e\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u0418 \u0442\u0430\u043a \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0435 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const encodeAndJoinPair = pair =&gt; pair   .map(encodeURIComponent)   .join('=');  const createQueryString = objectParams =&gt; Object   .entries(objectParams)   .map(encodeAndJoinPair)   .join('&amp;'); };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>utils.js<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0434\u0435 \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<p>  <\/p>\n<h4 id=\"urlsearchparams\">URLSearchParams<\/h4>\n<p>  <\/p>\n<p>\u0418 \u0442\u0443\u0442 \u043d\u0430 \u0441\u0446\u0435\u043d\u0443 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 Web API. <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/URLSearchParams\">URLSearchParams<\/a> \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a \u0440\u0430\u0437 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>  <\/p>\n<p>\u0418 \u0432\u0435\u0441\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0434\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const createQueryString = objectParams =&gt; new URLSearchParams(objectParams).toString();<\/code><\/pre>\n<p>  <\/p>\n<p>\u041b\u043e\u0436\u043a\u043e\u0439 \u0434\u0435\u0433\u0442\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Internet Explorer, \u043d\u043e \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0438\u0444\u0438\u043b\u043b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/www.npmjs.com\/package\/url-search-params-polyfill\">https:\/\/www.npmjs.com\/package\/url-search-params-polyfill<\/a> .<\/p>\n<p>  <\/p>\n<h4 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0434 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u043c, \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u044b\u043c, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0435\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c.<br \/>  \u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u0430\u044f \u0432\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 Web API.<\/p>\n<\/div>\n<p> \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\/post\/489888\/\"> https:\/\/habr.com\/ru\/post\/489888\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489888\/\">\n<p>\u041a\u0430\u043a-\u0442\u043e \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 URL-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 <code>iframe<\/code> src-\u0430\u0442\u0440\u0438\u0431\u0443\u0442.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u0448\u043d\u0435\u0439, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439 \u0438\u043b\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0440\u0430\u0437 \u0442\u0430\u043a\u043e\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0436\u0438\u0432\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u0435, \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043c\u043e\u043b\u0447\u0430\u0442\u044c, \u0430 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f best-practices.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043e\u043d, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const createQueryString = (param1, param2, objectId, timestamp, name) =&gt; {   const encodedTimestamp = encodeURIComponent(timestamp);   const delimiter = '&amp;';   const queryString = `${param1}${delimiter}         param2=${param2}${delimiter}         objectId=${objectId}${delimiter}         itemTimestamp=${encodedTimestamp}${delimiter}         itemName=${name}`;   return queryString.replace(\/ \/g, '%20'); };<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0414\u043b\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0438, <code>param1<\/code> \u0438 <code>param2<\/code> \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0438\u043c\u0435\u044e\u0442 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u0410 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0434\u043b\u044f URL \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<\/em><\/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-299228","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299228","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=299228"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299228\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}