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

Bug: JS warning when multiples spaces in title #154

Closed
rngtng opened this issue Dec 10, 2021 · 3 comments
Closed

Bug: JS warning when multiples spaces in title #154

rngtng opened this issue Dec 10, 2021 · 3 comments

Comments

@rngtng
Copy link
Contributor

rngtng commented Dec 10, 2021

Another tiny one: I figured I get a js warning (in vscode) when request title has more than one space:

### Foo Bar Baz
GET http://httpbin.org

Warning: Javascript Keyword Foo_Bar Baz not allowed as name. Haven't test it, but probably this breaks even the @ref option for following requests..

On a side node: I'd expect the name conversion into lower camelcase: fooBarBaz !?

@AnWeber
Copy link
Owner

AnWeber commented Dec 10, 2021

I love javascript, but how javascript implemented String.replace is fucking stupid.

// wrong
"foo foo bar".replace(' ', '_');
// wrong
"foo foo bar".replace(/\s/u, '_');
//right
"foo foo bar".replace(/\s/gu, '_')

AnWeber added a commit that referenced this issue Dec 10, 2021
@rngtng
Copy link
Contributor Author

rngtng commented Dec 11, 2021

Wow! Indeed WTF:

If pattern is a string, only the first occurrence will be replaced.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

thanks the fix

@AnWeber
Copy link
Owner

AnWeber commented Dec 11, 2021

Exactly. I know the peculiarity of replace actually well, but would have remembered that regex solves my problem. I forgot about the /g flag. I switch programming languages too often lately.

@AnWeber AnWeber closed this as completed Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants