Skip to content

Prettier format url path with number incorrectly #5654

Closed

Description

@jasonxia23

Prettier 1.15.3
Playground link

--parser css

Input:

body {
  background: url(http://123.example.com);
}

Output:

body {
  background: url(http://123example.com);
}

Expected behavior:

Activity

  1. ikatyang commented on Dec 18, 2018

    @ikatyang
    Member

    As a workaround, you could use quoted url for now:

    Prettier 1.15.3
    Playground link

    --parser css

    Input:

    body {
      background: url('http://123.example.com');
    }

    Output:

    body {
      background: url("http://123.example.com");
    }
  2. added
    priority:high
    lang:css/scss/less
    on Dec 18, 2018
  3. jasonxia23 commented on Dec 19, 2018

    @jasonxia23
    Author

    Maybe I can help to fix this. Could you give me some advise.

  4. lydell commented on Dec 19, 2018

    @lydell
    Member

    As far as I remember, the issue is that the parser doesn’t treat the whole url(...) thing as one token. Instead, it thinks it’s a general function and splits it into url, (, http, :, /, /, ..., ). So all sorts of weird stuff can happen.

  5. jasonxia23 commented on Dec 27, 2018

    @jasonxia23
    Author

    I have spent some time on parser-postcss.js and printer-postcss.js. If I am not making a mistake, tokenizing happens in parser-postcss.js, right? Will it lead to other errors if I just take url(...) as one token. @ikatyang

  6. ikatyang commented on Dec 27, 2018

    @ikatyang
    Member
  7. alexander-akait commented on Dec 27, 2018

    @alexander-akait
    Member

    Bug in parser, postcss-values-parser broken with url (when it is not "string") #5654 (comment) and i am banned in postcss-values-parser and i can't send a PR (owner don't love me 😕 ). Maybe we need switch on postcss-value-parser (we use this in stylelint, webpack loaders/plugins and other repos) and it is works as expected and no problems, but it is require rewrite many logic. I am planned this on next year (January/February).

  8. jasonxia23 commented on Dec 28, 2018

    @jasonxia23
    Author

    Seems to be complicated. Would be glad if I can do some help.

  9. alexander-akait commented on Dec 28, 2018

    @alexander-akait
    Member

    @jasonxia23 I can't, i am banned, sorry, this guys violated Code of Conduct many times and i don't want use his code and work with him also, so we will switch on better and right solution like postcss-value-parser in next year as i said above, anyway feel free to fix this problem on prettier side, you can check isValidUrl here https://github.com/prettier/prettier/blob/master/src/language-css/parser-postcss.js#L31 (you can get logic ) and return value-url node and implement how we should print value-url (maybe better name)

  10. jasonxia23 commented on Dec 29, 2018

    @jasonxia23
    Author

    @evilebottnawi Maybe parser should not parse 123.example.com into 123., example, . and com, which cause the issue directly.

  11. lydell commented on Dec 30, 2018

    @lydell
    Member
  12. shellscape commented on Jan 30, 2019

    @shellscape
    Contributor

    @lydell @jasonxia23 evilbotnawi is banned from my repos because he has violated the code of conduct in my repos repeatedly, is generally a toxic individual to work with, and (as evidenced by his comments here) likes to repeat lies about me on various social media sites.

    I'm more than happy to help to resolve this bug, but if the intention of the project is to just use a different module soon anyways, I'll keep my focus on the new version rewrite instead. I won't be offended at all I promise, I just have limited time because we'll be welcoming a child soon 😄

  13. shellscape commented on Feb 3, 2019

    @shellscape
    Contributor

    I have published v3.0.0-beta.2 of postcss-values-parser. There are a lot of breaking changes as the entire parser was rewritten, but this should resolve most of the issues in Prettier associated with the module. If you all would like assistance upgrading, please let me know, I'm happy to help.

  14. added a commit that references this issue on May 29, 2020
  15. added
    locked-due-to-inactivity
    on Aug 28, 2020
  16. locked as resolved and limited conversation to collaborators on Aug 28, 2020
  17. added theissue type on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:css/scss/lesslocked-due-to-inactivitypriority:high

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions