eyeling 1.24.18 → 1.24.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HANDBOOK.md +1 -1
- package/package.json +1 -1
- package/test/playground.test.js +45 -2
package/HANDBOOK.md
CHANGED
|
@@ -3760,7 +3760,7 @@ When a user does want a portable link, the **Copy share link** button creates on
|
|
|
3760
3760
|
- edited programs are shared with a compact compressed `?state=...` payload,
|
|
3761
3761
|
- default option values are omitted from that payload to keep links small.
|
|
3762
3762
|
|
|
3763
|
-
If a generated compact share link is still very long, the playground reveals
|
|
3763
|
+
If a generated compact share link is still very long, the playground reveals a **Create TinyURL** option. The threshold is intentionally conservative, and the shortener handoff is explicit rather than automatic: after the user chooses that option, the browser uses a TinyURL API token stored locally in that browser to create the short link and copy it to the clipboard. The API request is sent as a POST with `referrerPolicy: "no-referrer"`, so an already-long playground URL is not leaked again as a large `Referer` header. If no token is provided, or if the API request fails, the playground falls back to opening TinyURL without putting the long URL in TinyURL's address bar, and it copies the compact share link so it can be pasted manually. This avoids silently sending encoded editor content to a third-party service while still making the account-backed TinyURL workflow one click after setup.
|
|
3764
3764
|
|
|
3765
3765
|
This keeps everyday use pleasant while preserving the important tutorial and issue-reporting workflow: a link can still capture the imported resource, the local editable overlay, background-knowledge mode, proof-comments mode, and HTTPS-dereferencing mode.
|
|
3766
3766
|
|
package/package.json
CHANGED
package/test/playground.test.js
CHANGED
|
@@ -790,6 +790,40 @@ async function main() {
|
|
|
790
790
|
})()`);
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
+
async function createTinyUrlWithStubInPage(longUrl, token, response) {
|
|
794
|
+
const payload = JSON.stringify({ longUrl: String(longUrl), token: String(token), response });
|
|
795
|
+
return await evalInPage(`(async () => {
|
|
796
|
+
const args = ${payload};
|
|
797
|
+
const originalFetch = window.fetch;
|
|
798
|
+
let seen = null;
|
|
799
|
+
window.fetch = async (url, options) => {
|
|
800
|
+
options = options || {};
|
|
801
|
+
seen = {
|
|
802
|
+
url: String(url || ''),
|
|
803
|
+
options: {
|
|
804
|
+
method: options.method,
|
|
805
|
+
headers: options.headers,
|
|
806
|
+
body: options.body,
|
|
807
|
+
cache: options.cache,
|
|
808
|
+
referrerPolicy: options.referrerPolicy,
|
|
809
|
+
hasSignal: !!options.signal,
|
|
810
|
+
},
|
|
811
|
+
};
|
|
812
|
+
return {
|
|
813
|
+
ok: true,
|
|
814
|
+
status: 200,
|
|
815
|
+
json: async () => args.response,
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
try {
|
|
819
|
+
const tinyUrl = await window.__eyelingPlaygroundCreateTinyUrl(args.longUrl, args.token);
|
|
820
|
+
return { tinyUrl, seen };
|
|
821
|
+
} finally {
|
|
822
|
+
window.fetch = originalFetch;
|
|
823
|
+
}
|
|
824
|
+
})()`);
|
|
825
|
+
}
|
|
826
|
+
|
|
793
827
|
async function loadUrlIntoEditor(url) {
|
|
794
828
|
const payload = JSON.stringify(String(url));
|
|
795
829
|
await evalInPage(`(() => {
|
|
@@ -950,8 +984,17 @@ ${JSON.stringify(last, null, 2)}`);
|
|
|
950
984
|
const longShare = await makeShareUrlDiagnosticsInPage();
|
|
951
985
|
assert.ok(longShare.length > longShare.threshold, `Expected test share URL to exceed threshold (${longShare.length} <= ${longShare.threshold})`);
|
|
952
986
|
assert.equal(longShare.needsShortener, true, 'Expected oversized share URL to request a shortener option');
|
|
953
|
-
assert.
|
|
954
|
-
assert.
|
|
987
|
+
assert.equal(longShare.shortenerUrl, 'https://tinyurl.com/app', 'Expected TinyURL app fallback handoff to avoid embedding the huge URL');
|
|
988
|
+
assert.equal(longShare.shortenerUrl.includes(encodeURIComponent(longShare.url).slice(0, 40)), false, 'Expected shortener fallback URL not to carry the generated share URL');
|
|
989
|
+
const tinyUrlCreated = await createTinyUrlWithStubInPage(longShare.url, 'test-token-123', {
|
|
990
|
+
data: { tiny_url: 'https://tinyurl.com/eyeling-test' },
|
|
991
|
+
});
|
|
992
|
+
assert.equal(tinyUrlCreated.tinyUrl, 'https://tinyurl.com/eyeling-test', 'Expected TinyURL API response to produce a short URL');
|
|
993
|
+
assert.equal(tinyUrlCreated.seen.url, 'https://api.tinyurl.com/create', 'Expected TinyURL API create endpoint');
|
|
994
|
+
assert.equal(tinyUrlCreated.seen.options.method, 'POST', 'Expected TinyURL API POST request');
|
|
995
|
+
assert.equal(tinyUrlCreated.seen.options.headers.Authorization, 'Bearer test-token-123', 'Expected bearer token authorization');
|
|
996
|
+
assert.equal(tinyUrlCreated.seen.options.referrerPolicy, 'no-referrer', 'Expected TinyURL API request not to send a long Referer');
|
|
997
|
+
assert.match(String(tinyUrlCreated.seen.options.body || ''), /"url":/, 'Expected TinyURL API body to include the long URL');
|
|
955
998
|
endTest();
|
|
956
999
|
|
|
957
1000
|
// 7) log:query can produce Turtle; that should stay in plain source output without Markdown tabs.
|