Open jlengstorf opened 7 years ago
Thanks; I prefer the former; we should trap the error; then if google changes what length they like, we don't have to chase them.
@buzzdecafe It looks like the REPL has a hard-coded link to the master bundle, so I'm not sure how to test this locally, but I think the following in repl/lib/js/googl.js:40
would be a quick-and-dirty fix to at least give some feedback:
const getShortUrl = R.map(R.compose(setValue, R.prop('id')));
+ const getErrorMessage = R.map(setValue, R.path(['error', 'message']));
+ const handleResponse = R.ifElse(
+ R.has('error'),
+ getErrorMessage,
+ getShortUrl,
+ );
const futureXhr = getResponse(apiUrl);
- export default () => makeShortUrlBtn.addEventListener('click', () => futureXhr.fork(error, getShortUrl));
+ export default () => makeShortUrlBtn.addEventListener('click', () => futureXhr.fork(error, handleResponse));
If there's a way to test the REPL locally that I'm missing, let me know and I'll send a proper PR.
repl has its own repo: https://github.com/ramda/repl
it's been a while since i've done any work in there, so i don't recall how to build/run locally.
ping @craigdallimore @MattMS
It's been a while since I looked at the REPL integration with the site, so I'll go through it again now and see how it's all setup.
It seems like the REPL code is still in the site repo, so the new REPL code hasn't been integrated yet. I'm not sure of the current state of the REPL code (in either repo), so I'll try and make some time tomorrow to check it out (it's a bit late here now).
In the REPL, trying to create a share link with a large code sample will fail. This happens because Google's URL shortener won't accept URLs over a certain length and returns a
400
error.The shortener seems to start throwing errors at 4,096 characters.
A possible solution would be an error handler for
400
errors from Google that checks the URL length and offers a helpful error message:Alternatively, an event handler on the function that changes the URL could do a quick check for length and disable the share button with a
title
message explaining that the current code snippet is too long to be shared.