Report WP
Report WP
INTRODUCTION
A URL shortener is basically a way to make a long URL (Uniform Resource Locator)
shorter. URL shortening services are Web tools (or services) that allow you to provide a
long URL to a specific webpage and obtain a much shorter URL from the service
provider. One of the most common reasons why people want a short URL is to save
character space when typing messages on Twitter and other micro blogging sites. These
sites limit the number of characters you can use in an update and a long URL means less
space for a message.
Another good reason to use a URL shortener is when you have a lengthy and unattractive
URL on an ISP or free Web hosting service. In some cases you can use a shortener to
have a more pleasing Web address. Short URLs are also useful when sharing an
extremely long URL over instant messaging or in email where there is a chance the long
link could be broken during message transmission. Others may want to use a short URL
to hide the originating domain name when posting a URL.
This can be for legitimate reasons, but unfortunately this is a feature of short URLs that is
frequently abused by spammers. We have built a simple URL shortener which does not
need a database system to host it. Instead, jsonstore.io is been used. jsonstore.io is used
to store information about our long URL. We will need a jsonstore.io endpoint URL to
store data.
2
PROBLEM STATEMENT
To Design an Algorithm that generates a shorter URL which can be used in place of Long
URL for Convenience and Reliability.
HARDWARE
• LAPTOP(PC)
SOFTWARE
• Any OS Browser with JavaScript enabled
FLOW CHART
3
IMPLEMENTATION
4
Index.html
<html>
<head>
<title>Simple URL Shortener</title>
</head>
<body>
<input type="url" id="urlinput">
<button onclick="shorturl()">Short The URL</button>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="main.js"></script>
</body> </html>
Main.js
var endpoint =
"https://www.jsonstore.io/8ba4fd855086288421f770482e372ccb5a05d906269a34da5
884f39eed0418a1";
function geturl(){
var url = document.getElementById("urlinput").value;
var protocol_ok = url.startsWith("http://") ||
url.startsWith("https://") || url.startsWith("ftp://");
if(!protocol_ok){ newurl = "http://"+url;
return newurl; }else{ return url;
}
}
function getrandom() {
var text = ""; var
possible =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
'data': JSON.stringify(this.url),
'dataType': 'json',
'contentType': 'application/json; charset=utf-8'
})
} function shorturl(){
var longurl = geturl();
genhash();
send_request(longurl);
}
var hashh = window.location.hash.substr(1)
if (window.location.hash != "") {
$.getJSON(endpoint + "/" + hashh, function (data) {
data = data["result"];
if (data != null) {
window.location.href = data;
}
}); }
OUTPUT SCREENSHOTS
6
7
8
CONCLUSION
A URL shortener is useful and commonplace online today. It has disadvantages but it also
has many advantages over using a long URL, especially for micro blogging. Ultimately,
just having a short URL to access your Web page tops the list of advantages, but it can
also help with keeping links intact in email or text messages and it can be useful for SEO
(search engine optimization) when you use a short URL service that allows you to choose
keywords in the short URL.
URL shortener services provide detailed tracking and analytics for each shortened URL.
This is useful to track how popular the short URL is and to see when it is published on
social media sites.