Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:03:49+00:00 2026-05-27T05:03:49+00:00

I have these strings which are addresses of files and folder: ../../../folder1/sub1/sub12/ ../../../folder1/ ../../../another-folder/

  • 0

I have these strings which are addresses of files and folder:

  1. ../../../folder1/sub1/sub12/
  2. ../../../folder1/
  3. ../../../another-folder/

I want to compare them using javascript – possibily jquery – to see if for example string 1 have a part egual to string 2 but something more saying that string 1 is child of string 2.

How can i do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:03:50+00:00Added an answer on May 27, 2026 at 5:03 am

    In case your string can contain also absolute paths or paths containing .. not only at the beginning I would recommend checking if .indexOf return 0 instead of anything that is not -1.

    It can help with cases like.

    var path1 = "/rootFolder/";
    var path2 = "../folder/rootFolder/";
    
    if (path2.indexOf(path1) === 0) {
      console.log("You want this");  // won't get executed => good
    }
    
    if (path2.indexOf(path1) !=-1) {
      console.log("You don't want this"); // will get executed => bad
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have strings with dates, and want to parse these into NSDate objects. Is
I currently have a listview which contains a couple of strings. These are called
I have an application which parses strings and passes them via jQuery to a
I want to display contents as (not existing) sub-folders. All those sub-folder strings should
I have a list of ~20,000 email addresses, some of which I know to
I have a PHP script which calls another script in order to add IP
I have a directory full of email files, which look like this: From: Scoop
I have a linux applications which sends data over UDP protocol. It uses these
I have JSON data which contents Strings and Image URLs, and I already parse
I have an application which downloads some data and I want to show that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.