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

Remove /wp-content filter from sanitising code #98

Open
falconmick opened this issue Mar 13, 2018 · 0 comments
Open

Remove /wp-content filter from sanitising code #98

falconmick opened this issue Mar 13, 2018 · 0 comments
Assignees

Comments

@falconmick
Copy link
Contributor

https://github.com/distilagency/starward/blob/master/server/init/api.js

line 19->20:

.replace(wpUrlRegex, '')
.replace(wpContentUrlRegex, `${WP_URL}/wp-content`);

This is a bad because applying a mass string manipulation is just a bad idea, it should be the responsibility of the component or query that works with that data to format data.

Where this is used?:
I think on an old project I was using links that WP generated for pages, by doing this above replace it would make the URL correct for starward navigation as WP slugs match up with Starward!
the line 20 was used to add the WP url back on after we blew it away.

Why remove it?
I was adding JSON schema to my project via a settings field. I was so confused why my JSON schema was changing when it shouldn't!! Turns out it was due to this.
Move the responsibility of URL fixing to the component using them or on the queries that understand that the data they're receiving are WP slugs that need translating to Starward.

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