GithubHelp home page GithubHelp logo

secretnest / shorturl Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 143 KB

Short url redirector with no database required. DotNet Core 3.1 and Net 5 version.

License: MIT License

C# 58.47% HTML 41.53%
redirection shorten-urls dotnet-core no-database shorturl

shorturl's Introduction

ShortUrl

Short url redirector with no database required. DotNet Core 3.1 and Net 5/6 version.

Language: C#

Platform: ASP.Net Core 3.1, Net 5/6

Features

  • No database required.
  • Multiple host names supported.

Installation

Management

  • Management
  • Edit the configuration file directly when HTTPS is not available.

Known Issue

  • Due to lack of support of http code 308 in IE on Windows 7 / 8.1, do NOT check "Use HTTP 308" / "Use HTTP 308 instead of 307" if you need to support old IE versions.

Work flow

When a request is received by ShortUrl, it will follow these steps.

  1. Gets the host from the HTTP Header.
    • When preferXForwardedHost in configuration file is set to true and X-Forwarded-Host exists in HTTP Header, gets the host from X-Forwarded-Host.
    • Gets the host from Host in HTTP Header.
  2. Gets the path segments from the HTTP Header as the access key.
  3. Enters the Global Management page when
    • The access key equals to Global Management Key. And,
    • The host is allowed to enter Global Management page when
      • The host exists(*1) in Global Management Enabled Hosts. Or,
      • The list Global Management Enabled Hosts is empty.
  4. Resolves by aliases when the host equals(*1) the Alias column of one record in Aliases from Global Management, choosing Target as the new value of host and restart this step. Aliases could be resolved recursively with 16 as the max depth.
  5. Processes the request against the domain when the host equals(*1) Domain column of one record in Domains from Global Management.
    1. Enters the Domain Management page when access key equals to Domain Management Key.
    2. Resolves by redirects when the access key equals(*2) the address column of one record in Redirects from Domain Management of this domain.
      • When the Target from the record matched is starting with >, gets the text after > from Target as the new value of access key and restart this step. Redirects could be resolved recursively with 16 as the max depth. Or,
      • Redirects to Target specified of the record matched.
    3. Redirects to Default Redirect Target specified in Domain Management of this domain if it is not empty.
  6. Redirects to Default Redirect Target specified in Global Management.

*1: Host name matching rules:

  • Host name matching is case insensitive.
  • Port number 80 or 443 should not present, but all others should and will be treated separately. For example:
    • The record "example.com" will be matched with the host "example.com", "example.com:80" and "example.com:443".
    • The record "example.com:8080" will be matched with the host "example.com:8080" only.
  • The record with the key ends with ":80" or ":443" in domains or aliases will not be matched unless it's pointed by other matched alias records.

*2: Name matching could be case sensitive or insensitive, based on the setting Ignore Case When Matching specified in the Domain Management of the related domain.

When redirecting:

  • HTTP 308 will be used, when Use HTTP 308 instead of 307 or Use HTTP 308 is selected. Or HTTP 307 will be used.
  • When Attach Query Process is enabled and the query string exists from the request:
    • When character ? presents in the target of the redirection, & and the query string from the request will be appended.
    • When character ? absents from the target of the redirection, ? and the query string from the request will be appended.
  • When Attach Query Process is disabled, the query string, if exists, from the request will be dropped and will not be passed into the redirection target.

shorturl's People

Contributors

scegg avatar sgjsakura avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ponson028 fhdk

shorturl's Issues

Use 308 instead of 301, 307 instead of 302

Try to change to use 308 instead of 301 when making a permanent redirect, use 307 instead of 302 when making a normal redirect.

UI: Checking all texts with 301 and change into 308, 302 to 307.
Code: Change all code using 301 to 308, 302 to 307.

These will keep the same verb after redirecting.

Change address repeatedly

When changing an address of a record repeatedly, a wrong error is returned.

Step to repo:
1 open a domain setting page.
2 change address block of a record and click update.
3 change it again and click update.

Expected: new address is accepted.

Actual: An error is returned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.