ampproject / ampproject/amphtml

Support file:/// as prefix in addition to localhost

Open
#33,099 1 comment 0 reactions 0 assignees View on GitHub
Stale Type: Feature Request
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

## Describe the new feature or change to an existing feature you'd like to see

Currently if you have AMP files on disk, it checks that relative URLs start with http:// or localhost - you cannot use file:/// as a prefix. This means if you have files on disk, say checked out from a git repo, you cannot test those files by opening them directly in chrome. You have to spin up a web server to try out your AMP page (web story in my case).

![image](https://user-images.githubusercontent.com/5702163/110072954-72566200-7d33-11eb-9ffa-7900b2fba6c1.png)

![image](https://user-images.githubusercontent.com/5702163/110072871-4cc95880-7d33-11eb-95b7-2ef28b546aac.png)

I would like to create a debug AMP pages without having to start up a web server.

## Describe alternatives you've considered

I check my code out using git. Spinning up a web server inside the checkout git directory feels like an overkill. I just want to open the web page with all the images, videos etc it references in the same directory using relative paths. This does not work because the original HTML page was opened using a file:/// prefix (I am on Windows).

What I instead do is push the changes to GitHub and use it as my web server, but it means I have to commit and push as part of my debugging process, which feels wrong. It also causes caching problems as my changes are not published immediately.

Contributor guide

Open the contributing guide

Research direction

Start by locating the AMP validation that currently accepts relative URLs only with http:// or localhost, then reproduce the behavior by opening an AMP file directly in Chrome with a file:/// URL. Done means local AMP pages accept file:/// as a valid prefix and their relative images, videos, and other resources work without a web server.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.