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

Fix isJSON() to recognize leading tabs and new line characters #1424

Merged
merged 3 commits into from
Jul 28, 2017

Commits on Jul 27, 2017

  1. Fix isJSON() to recognize leading tabs and new line characters

    When a user pastes JSON into the editor, the editor prompts to convert it to YAML. This works if the JSON contains leading spaces:
    ```
      	 {"foo": "bar"}
    ```
    but does not currently work if the leading whitespace includes new line characters or tabs -- in this case JSON is pasted "as is".
    ```
    
    
    {"foo": "bar"}
    ```
    
    This PR improves the `isJSON()` function to recognize `\t`, `\r` and `\n` in the leading whitespace. Tabs and new lines are allowed in the leading whitespace according to [RFC 4627](https://tools.ietf.org/html/rfc4627) (section 2) and [ECMA-404](https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf) (section 4):
    > Insignificant whitespace is allowed before or after any of the six structural characters.
    > 
    > The whitespace characters are: character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), and space (U+0020).
    hkosova committed Jul 27, 2017
    Configuration menu
    Copy the full SHA
    c9ffeaf View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2017

  1. Configuration menu
    Copy the full SHA
    4ced682 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e4da25f View commit details
    Browse the repository at this point in the history