Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ricksouth/ntms.link

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

30 Commits

Repository files navigation

A basic URL shortener.

It gets the URLS to shorten from a JSON file:
https://github.com/ricksouth/ntms.link/blob/main/urls/shortened_urls.json

{
	"github" : "https://github.com/ricksouth",
	"curseforge" : "https://curseforge.com/members/serilum/projects",
	"modrinth" : "https://modrinth.com/user/serilum"
}


Which a basic JavaScript turns into a new URL: (via a catch-all 404 page)
https://github.com/ricksouth/ntms.link/blob/main/assets/js/script.js

document.addEventListener('DOMContentLoaded', function() {
	var url = document.URL + "";
	url = url.replaceAll("?p=/", "");
	loadJSON('/urls/shortened_urls.json',
		function(data) {
			var from = url.split("link/")[1]
			if (from in data) {
				var to = data[from];
				window.location.replace(to);
				return;
			}
			window.location.replace("https://github.com/ricksouth/ntms.link");
		},
		function(xhr) { }
	);
}, false);


These URLS are now shortened via Github Pages:

Anything else will link back to this repository:

That's it! 🀷

About

A basic URL shortener using Github Pages, a catch-all 404 page, plain JS and a JSON file.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /