Skip to content

Commit

Permalink
rearranges file cleaning to make more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank M. Taylor committed Apr 3, 2024
1 parent 4775273 commit fe5867f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/selector-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ export default class SelectorFinder {
*/
static async grabScreensAsync(nodes, url) {
await forEachAsync(nodes, async (element, index) => {
let fileName = `${url}-${index}`;
const cleanUrl = url
.replace(/http(s?)(:\/\/)/, '') // get rid of protocol
.replace('.', 'dot') // replace . with dot
.replace(/\.((x|r|s)?(htm(l?))|jsp|php|asp|cfm)(x?)/gi, '') // remove file extensions
.replace(/\//g, '_'); // directories to underscores
let fileName = `${cleanUrl}-${index}`;
fileName = fileName
.replace(/http(s?)(:\/\/)/, '')
.replace('.', 'dot')
.replace(/\.((x|r|s)?(htm(l?))|jsp|php|asp|cfm)(x?)/gi, '')
.replace(/\//g, '_')
.replace('--', '-')
.replace('_-', '-');
.replace('--', '-') // dangling double-hyphens
.replace('_-', '-'); // a final / that would convert to _

await SelectorFinder.grabScreenAsync(element, fileName);
});
Expand Down

0 comments on commit fe5867f

Please sign in to comment.