Determine whether a URL has already been encoded using the encodeURI function

Attempting to accomplish this task in VBScript/JScript to prevent re-encoding.
Is it necessary to check for the presence of "%" ? Are there other purposes for "%" in URLs?
Thank you.

Edit: Oh, perhaps the original encoding method wasn't encodeURI.
I am attempting to gather URLs from the browser and save them after encoding with encodeURI.
However, if the URL is already encoded, applying another round of encoding will render it incorrect.

Answer №1

One method could be attempting to decipher the code and then contrasting it with the initial URL. If there are differences or if the length is reduced, it's likely that the original URL was already encoded.

Answer №2

Loop through the characters of the URL and check for any that are not permitted in a URL.

If any illegal characters are found, encode them. If no illegal characters are present, there is no need for action.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be the reason for my function not being executed in this particular scenario with my calculator HTML code?

Memory = "0"; Current = "0"; Operation = 0; MAXLENGTH = 30; alert("yea"); function AddDigit(digit) { alert("yea"); if (Current.length > MAXLENGTH) { Current = "Aargh! Too long"; } else { if (eval(Current) == 0) { Current = dig; ...

Incorporate fresh data into dropdown options upon selection using Vue3

Can anyone assist me with populating specific input fields on a form using Vue 3? Currently, when a user selects an option from my dropdown menu, all inputs are displayed instead of just the relevant ones. Below is the select dropdown code: <select v- ...

MongoDB failing to enforce unique constraints on partial indexes

I have a set of data that looks like this: { name: "Acme co." add4: "", nationalNumber: "+13412768376" }, { name: "Acme Inc.", add4: "6345", nationalNumber: "" } My goal is to insert these records into a collection, but only if they are uni ...

Issue with Chart.js V3.20: Struggling to Filter Legend Labels

Building a dynamic line chart using Chart.js with the capability of up to 19 datasets. The issue arises when there are less than 19 datasets, as the legend still displays for these unused datasets. Previously, a function was used in Chart.js 2.6.0 options ...

Styling elements with CSS

I've been attempting to align a button to the right of another button. The example above illustrates what I'm trying to achieve. I used Bootstrap to build it, which has a useful navbar feature for layout. However, despite my efforts to use right ...

Issues arise when using jQuery's ajax() method with processData set to false, as it still adds form data to the URL, among

Today, I am delving into the world of jQuery to enhance a form's functionality, particularly to interact with a MySQL database. Here is the form I am working with: <form class="loginform" id="loginform" name="loginform"> <input type="ema ...

Determine the number of properties in each object entry

My goal is to determine the number of properties within each object in an array... value = [ 0: { personId: "0003678", seniorStatus: "Yes", juniors: "maybe" }, //3 1: { personId: "0001657", seniorStatus: "No", juniors: "No" }, //3 2: { person ...

Nodejs: code functions properly at my residence, but encounters ECONNREFUSED error when executed in the workplace

Completely new to JavaScript and Node.js, I decided to follow a guide on web scraping with Node.js from . The code worked perfectly at home, but when I tried to implement it at work, I encountered a persistent issue. Error: connect ECONNREFUSED at errnoEx ...

A Node.js feature that enables atomic file replacement, triggering watchers only once

I have a unique scenario where I need to handle two types of processes. One process is responsible for writing a file, while the other processes are required to read it whenever there is a change. In my research, I came across fs.watch as a solution to ke ...

What is the best way to set up a watcher for q-input and q-date components in Quasar

I have a component named "display.vue" which includes a date picker for users to select a date. //display.vue <template> <div class="q-pa-md" style="max-width: 300px"> <q-input filled v-model="date" mask=& ...

Leverage OpenID Connect in Azure Active Directory with authentication code flow

Currently, I am developing an authentication system for a NodeJS and Express web application that requires users to be directed to Microsoft SSO. To achieve this, I am utilizing passport-azure-ad and OpenID Connect. My main query is - Is it mandatory to ...

What causes a 500 error when using PHP eval in conjunction with AJAX?

Working within a system where all PHP code resides in a database for dynamic alterations has presented me with an interesting challenge. While the code displays perfectly on the page, calling the same code via AJAX triggers a frustrating error 500. I' ...

Enhancing the theme using material-ui@next and typescript

While developing my theme using material-ui, I decided to introduce two new palette options that would offer a wider range of light and dark shades. To achieve this, I extended the Theme type with the necessary modifications: import {Theme} from "material ...

What causes the React Query cache to be cleared upon page reload?

Hi there, I am new to Next.js and React Query. I would really appreciate any help or advice. I apologize for any mistakes in my English language skills. Currently, I am using Next.js v12 and React Query v3, along with the React Query DevTools. On one of ...

Looking to access XML file data using Vue.js on the server side?

I am trying to access an XML file located in a specific path on the server side using VueJS without using jQuery. Can you provide me with some ideas or advice? Scenario: 1. The file is stored at /static/label/custom-label.xml. 2. I need to read this file ...

Is there a way to fix the error "The requested resource does not have the 'Access-Control-Allow-Origin' header" within Express using Firebase functions?

Trying to send an email through nodemailer using Firebase functions, but encountering errors. The data for the email will come from a form. Error message: Access to XMLHttpRequest at 'my-firebase-functions' from origin 'my-angular-web-app&a ...

Using ng-bind-html does not offer protection against cross-site scripting vulnerabilities

I utilized ng-bind-html to safeguard against cross site scripting vulnerabilities. I came across information about sanitization and engaged in a discussion at one forum as well as another informative discussion. However, I encountered an issue where it di ...

Convert Object Keys to Month Format for Sequential Display of Months in AngularJS

I'm having trouble formatting an object key to display months chronologically. I can't figure out what I'm doing wrong. Here's the code in the view: <div ng-repeat="month in months | orderBy: 'english' | date: 'MMMM&a ...

The functionality to disable the submit button for unchecked radio buttons is not functioning properly

I am currently working on a form where I need to disable the submit button until all fields are filled out. Everything is functioning properly for other field types, EXCEPT FOR RADIO BUTTONS. Even when we do not select a radio option, the Submit button s ...

The jQuery AJAX call is successful in Firefox, but unfortunately, it is not working in Internet Explorer

I've encountered a perplexing issue with an AJAX call. It's functioning perfectly fine in Firefox, but for some reason, it's not working in IE. Curiously, when I include an alert() specifically for IE, I can see the returned content, but the ...