MCPcopy Index your code
hub / github.com/utterance/utterances / assertOrigin

Function assertOrigin

src/utterances.ts:139–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137}
138
139export async function assertOrigin() {
140 const { origins } = await getRepoConfig();
141 const { origin, owner, repo } = page;
142 if (origins.indexOf(origin) !== -1) {
143 return;
144 }
145
146 document.querySelector('.timeline')!.lastElementChild!.insertAdjacentHTML('beforebegin', `
147 <div class="flash flash-error flash-not-installed">
148 Error: <code>${origin}</code> is not permitted to post to <code>${owner}/${repo}</code>.
149 Confirm this is the correct repo for this site's comments. If you own this repo,
150 <a href="https://github.com/${owner}/${repo}/edit/master/utterances.json" target="_top">
151 <strong>update the utterances.json</strong>
152 </a>
153 to include <code>${origin}</code> in the list of origins.<br/><br/>
154 Suggested configuration:<br/>
155 <pre><code>${JSON.stringify({ origins: [origin] }, null, 2)}</code></pre>
156 </div>`);
157 scheduleMeasure();
158 throw new Error('Origin not permitted.');
159}

Callers 1

submitFunction · 0.85

Calls 2

getRepoConfigFunction · 0.90
scheduleMeasureFunction · 0.90

Tested by

no test coverage detected