LuckPermsWeb icon indicating copy to clipboard operation
LuckPermsWeb copied to clipboard

Allow for spaces between quotes in nodes

Open callumxzr opened this issue 5 years ago • 9 comments

When trying to add prefixes to already created ranks on the LuckPerms editor, it doesn't allow spaces. Not sure if there is anyway you can fix this, as it sets anything after a space as another permission.

Maybe you could add a separate option for prefixes, or maybe allow " ".

callumxzr avatar Nov 24 '19 10:11 callumxzr

Is this for the new version of the editor? I need to figure out a good way to handle this.

Turbotailz avatar Nov 24 '19 10:11 Turbotailz

Is this for the new version of the editor? I need to figure out a good way to handle this.

Yes.

callumxzr avatar Nov 24 '19 10:11 callumxzr

For anyone who wants to help with this (I am not an expert in regex):

Currently when entering new permissions, this regex is used to check for multiple permissions being added - /,\s*|,|\s+|\s*-{1}\s+/

This works perfectly for any cases where there are multiple permissions separated by space, or multiple spaces and hyphens (as if it were copied from a yaml file). The regex needs to also check for quotes " " and make sure the quotes are kept intact, no matter how many spaces are added inside of them.

Here's an example on regexr: https://regexr.com/4smc5
Basically it needs to keep the same behaviour but not split the permission with quotes.

Hoping that someone will have a solution for this :)

Turbotailz avatar Jan 21 '20 22:01 Turbotailz

Maybe only split on comma (similar to how tags on various sites work)?

Andre601 avatar Jan 21 '20 22:01 Andre601

But then users can't paste multiple permissions from various sources. It is almost always spaces, or spaces with hyphens.

Turbotailz avatar Jan 21 '20 22:01 Turbotailz

\s*(?:,|-)?\s+

That alone is an improvement. Working on one that handles those cases properly.

BrainStone avatar Jan 21 '20 23:01 BrainStone

After a bit of discussion the question came up as to why you don't just split at the newline?
That leaves no room for speculation where the nodes are separated.

And to trim them, always trim the left side and if it's then not a prefix or suffix node, also trim the right side.

BrainStone avatar Jan 21 '20 23:01 BrainStone

Because new lines aren't supported in a text input, they are converted to spaces.

I feel like it should be a requirement that prefixes/suffixes which include spaces should be wrapped in quotes.

Turbotailz avatar Jan 22 '20 00:01 Turbotailz

I did some searching and found \s+(?=([^"]*"[^"]*")*[^"]*$) https://regexr.com/54d2o

RealTrashPanda avatar May 12 '20 02:05 RealTrashPanda