ampproject / amp-viewer

Apache License 2.0
38 stars 34 forks source link

Add methods to sanitize manually specified CDN URLs. #65

Closed stephen-deg closed 7 years ago

stephen-deg commented 7 years ago

Manually specified runtime versions or any query/hash parameters are not valid for AMPKit CDN URLs and need to be sanitized if they are provided.

For instance, given this manual AMP version URL: https://www-theverge-com.cdn.ampproject.org/v/s/www.theverge.com/platform/amp/circuitbreaker/2017/9/6/16254802/new-iphone-change-event?amp_js_v=0.1#test=1&visibilityState=prerender

the AMPKit appropriate sanitized URL is: https://www-theverge-com.cdn.ampproject.org/c/s/www.theverge.com/platform/amp/circuitbreaker/2017/9/6/16254802/new-iphone-change-event

Add new unit tests for the code. Required some modifications of existing unit tests since these error corrections were being used to test framework code in a few places.