1

I have two different directories like

  • dir 1 --> template 1 --> tpl1.html
  • dir 2 --> template 1 --> tpl1.html

My requirement is dir 1 has all the js files, css files, icons etc.. but dir 2 will have only html file with same name like dir 1 html files.

Based on different domains on page load i need to make a decision which html needs to load.

I am using require js "text", I want to make the path of the text!path more dynamic.

Inside directory2 i want to check the length first, and then I want to pick the file.

Please suggest me a approach on this.

1

2 Answers 2

0

I'm not sure if this is what you mean "check the length of the directory", Use split().

var directory = 'dir0/dir1/dir2';
var directories = directory.split('/');
var count = directories.length;
Sign up to request clarification or add additional context in comments.

Comments

0

Use Like this Way to check URL contains folder or File..

function isFile(pathname) {
    return pathname
        .split('/').pop()
        .split('.').length > 1;
}

function isDir(pathname) { return !isFile(pathname); }

console.log(isFile(document.location.pathname));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.