Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to create REPL share links with large amounts of code fails. #174

Open
jlengstorf opened this issue May 12, 2017 · 5 comments
Open
Labels

Comments

@jlengstorf
Copy link

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:

Cannot create a share link for URLs over 4,096 characters in length. Please reduce the size of your sample code to share.

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.

@buzzdecafe
Copy link
Member

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.

@jlengstorf
Copy link
Author

@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.

@buzzdecafe
Copy link
Member

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

@MattMS
Copy link
Member

MattMS commented May 12, 2017

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.

@MattMS
Copy link
Member

MattMS commented May 12, 2017

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants