Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Challenge: URLEncoder Description: Create a properly formatted URL string and present it in the Console based on input from the user and a provided URL

Challenge: URLEncoder

Description: Create a properly formatted URL string and present it in the Console based on input from the user and a provided URL format.

Purpose: This application provides experience with user input and interaction in the Console, manipulating and building strings, working with characters, URI/URL formats and rules, structuring programs, and writing programs in C#/.NET.

Requirements:

Project Name: URLEncoder Target Platform: Console Programming Language: C#

A Uniform Resource Identifier is a string of characters designed for unambiguous identification of resources and extensibility via the URI scheme. The most common form of URI is the Uniform Resource Locator, frequently referred to informally as a web address.

A user has a need to generate URLs for files they are storing on a server. The purpose of this program is to generate the URL string so the user doesnt have to type it out. The program asks the user for several pieces of information and then uses it to generate the URL string and presents it in the Console where the user can copy it. This is being done so the user doesnt have to type out the URL and helps avoid mistakes from typing and from the use of invalid characters in a URL.

The following is the format for a URL that is to be generated by the program.

https://companyserver.com/content/[project_name]/files/[activity_name]/[activity_name]Report.pdf

The [project_name] and [activity_name] are placeholders for pieces of information that go in the string. The [ ] do not get included in the string. They surround an identifier for the piece of information and are not part of the content.

So, if [project_name] is DesignLab and [activity_name] is Furnishings then the URL is to be https://companyserver.com/content/DesignLab/files/Furnishings/FurnishingsReport.pdf

There are a couple of rules that have to be adhered to when creating URLs.

No spaces are allowed in URLs. So, if [project_name] is Design Lab it cant be included as-is in the URL. Spaces in URLs must be replaced with %20. The URL can contain Design%20Lab. If a space is present in the user input it must be converted to %20. Note: spaces can also be replaced with a +, but for this assignment spaces are to be converted to %20.

In addition to spaces, there are other characters that may not be placed in URLs. The HTML URL Encoding Reference (Links to an external site.) from w3schools shows how characters that arent allowed in a URL can be converted to a %[number] value that can be in the URL.

control characters: these are ASCII coded characters 001F and 7F hexadecimal

delimiter characters: < > # % and "

If a control character appears in the content provided by the user, the user is to be given feedback that the input is invalid because it contains a control character and they are to be asked to provide a different input.

If a delimiter appears in the content provided by the user, the delimiter character is to be converted into its %[number] URL encoded format. For example, < is to be encoded as %3C and > is to be encoded as %3E. The values for the other characters can be found in the documentation provided above.

There are some other characters that are reserved for use in some parts of the URL. They may not be allowed in one part of the URL even if they are allowed in other parts. These characters are also to be converted to their URL encoded format using %[number]. The following characters are reserved within a query component, have special meaning within a URL, and are to be converted.

; / ? : @ & = + $ ,

The following list of characters are not disallowed, but they may cause problems. They should also be converted to their URL encoded format.

{ } | \ ^ [ ] `

The following is an example to illustrate the application of the rules.

Project Name: Design Lab

Activity Name: Network>Implementation

Result URL: https://companyserver.com/content/Design%20Lab/files/Network%3EImplementation/Network%3EImplementationReport.pdf

Your application, when run, is to prompt the user for the Project Name and the Activity Name. If the input is invalid, the user should be re-prompted for the input with a feedback message. After the input is successfully received, the URL string is to be created based on the rules above and presented to the user in the Console.

After the URL is presented, the user is to be prompted if they want to create another URL. If they do, prompt them again for input. If not, exit the program.

The following are the goals for this program.

  1. Make it work according to the rules.
  2. Create a good user interaction. Care about how the program presents itself, how input is requested, and what feedback messages contain.
  3. Create a well-design application. Structure your application so it is modular and clean. Really think about how you are going to structure the data the app uses as well as the classes and functions. For the characters that needed to be converted to URL encoded values, think about how to do that so it is efficient and clean. Think about how easy it would be to add additional characters that are to be converted at a later time.
  4. Write the functionality yourself. Do not use a library function to URL encode the strings. Yes, a function exists that will take strings and convert them to URL encoded strings. You are not to use it. You are to write the code to perform the required operations yourself.
  5. Try your best! These challenges are the most beneficial to you when you make a valid attempt. If there are things you dont understand, the solution posted as part of the retrospective after the challenge will help bring understanding. If you dont make a valid attempt, then you really arent going to know what you dont know and wont get maximum benefit from a solution.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions