How do I differentiate b/w a ipfs url/path (content-addressed) from normal-url (location-addressed)?

I am trying to fetch nft-metadata for the nfts added on my platform. Some Nfts contains ipfs-urls as their tokenURIs and I need a mechanism to differentiate them from normal-urls (location-addressed urls).

I was using is-ipfs , but it gives false returns even for valid ipfs-urls!

 if (mtokenUri) {
            var res
            var data
        console.log("### ipfs url check ###")
        // false for "ipfs://bafybeihbsysdkemc3kyylegtfopkrcfiih4exnasoql2q36fb4zawlrwhy/volcano.json"

         //this is not very reliable
        if (isIPFS.urlOrPath(mtokenUri)) {
          //gives false even for a valid ipfs-url
          console.log('inside erc721 ipfs: ')

          isIpfsUrl = true
          console.log("*** 721 isIpfs url ***")
          // example ccid = 'QmPzhc9ezphJ85qJWfVVpeHkPieDJznpYduGhMYD7Z4Ac9'
          const cid_eg2 =
          try {
            res = await
            // data = await res.json()
          } catch (error) {

          //shows:cat {<suspended>}
        } else {

          //do normal fetch

          try {
            res = await fetch(mtokenUri)
            data = await res.json()
          console.log('erc721 normal fetch')
          console.log("*** Normal fetch data *** ")

          _imageUrl = data.image
          _name =
          _description = data.description

        } catch (error) {


is there any way to fetch both normal-urls and ipfs-urls ?

Here’s the stackoverflow link for the same –