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

Nice to know :) #48

Open
nikkesan opened this issue Mar 27, 2020 · 4 comments
Open

Nice to know :) #48

nikkesan opened this issue Mar 27, 2020 · 4 comments

Comments

@nikkesan
Copy link

let extension = lastFile.split(".")[1] || "";

I recall a previous mentor giving us this pro tip to use the 'path' module to return the endpoint file extension quite elegantly.
https://nodejs.org/api/path.html#path_path_extname_path

So you could use something like:

const path = require('path');

const extension = path.extname(endpoint); 
@oliverjam
Copy link

oliverjam commented Mar 27, 2020

waaaat how did I not know about that?! time to change every workshop...

@nikkesan can you post that in Slack so everyone can see it?

@Albadylic
Copy link

Albadylic commented Mar 27, 2020

@oliverjam I swear this used to be in the Tech Spike 😆

It's in bullet point three here

@oliverjam
Copy link

@Albadylic we have been using path.join to create filepaths (rather than doing it manually) which is what I assumed that was referring to. I think every team did that 🎉 but it would also be nice to drop all the awkward string splitting

@nikkesan
Copy link
Author

Will post on slack 👍

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

3 participants