michaeldera / image-accessibility-extension

A Google Chrome and Microsoft Edge extension to add alt attributes to images on webpages without them
MIT License
6 stars 3 forks source link

Issue with relative image urls #6

Closed nadchif closed 4 years ago

nadchif commented 4 years ago

Describe the bug When you load the "classic" php pages that don't use "pretty" urls, the modified url for the images with a relative src is incorrect.

To Reproduce Steps to reproduce the behavior:

  1. Go to a site that ends with a page + extension, like index.html or index.php that uses relative url for an image.
  2. Image a11y will now use the following fetch url https://image-recognition-function.azurewebsites.net/api/AnalyseImage?url=http://www.site.com/index.php/images/image.jpg
  3. See the following error from the API:
    {"code":"InvalidImageUrl","requestId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx","message":"Image URL is not accessible."}

Expected behavior Image a11y should use the following url https://image-recognition-function.azurewebsites.net/api/AnalyseImage?url=http://www.site.com/images/image.jpg to request description from API.

Desktop (please complete the following information):

Additional context i think a regex test against window.location.pathname, while determining the src variable in src/add-alt-attributes.js could be a way to resolve this

michaeldera commented 4 years ago

Had not considered this scenario. Would you like to work on a fix for this?

nadchif commented 4 years ago

Yes, sure

michaeldera commented 4 years ago

Awesome.