Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using without "domain" specified #263

Closed
719media opened this issue Sep 30, 2020 · 4 comments
Closed

Using without "domain" specified #263

719media opened this issue Sep 30, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@719media
Copy link

719media commented Sep 30, 2020

I am wanting to use this library with an external api that I can assume is using imgix for the URL when providing back data. The API feed includes the domain in all of the src fields already, and it would be nice if it wasn't required to "strip" the domain before feeding the URL to the component.

Looks like this library REQUIRES the definition of a domain, rather than allowing the src="" to actually just contain the domain. If I specify the domain as is required, and then also leave the domain in the src="" url, the library is not doing any checking to see that the domain already exists in the provided URL (which is understandably outside the scope of the library), and the URL is malformed.

It would be nice for this use case if the domain was "optional" in which case it would be assumed that all provided src="" urls would contain the domain.

Anyway, just an experience I had I wanted to share in case this was something that the library wanted to be able to handle.

@frederickfogerty
Copy link
Contributor

Hey @719media 👋 Fred here - creator of this library.

Firstly, I definitely agree that fully-qualified URLs is something we will support in the "path" attribute soon™. You're not the first person to mention this, so we will look at this soon!

Secondly, I just want to dive a little bit into when you say "the URL is malformed" after passing the full URL. If you provide no domain, I believe the library throws an error (at least, it should!). But the actual reason why the url is malformed is because we detect the "https" in the url and treat is as a proxy url, wherein we url-encode the path in accordance with our Web Proxy feature.

Hope this helps!

@frederickfogerty frederickfogerty added the enhancement New feature or request label Oct 1, 2020
@719media
Copy link
Author

719media commented Oct 6, 2020

Thanks for the reply. Ya, all makes sense. Just looking for an option to either dedupe when the url contains the domain already, or allow the domain to be optional.

The former (dedupe) allows for flexibility in support for URLs simultaneously having and not having a domain, although I'm sure a use case for an application having both URLs with the domain and without the domain is probably very uncommon (not my use case... my use case is all URLs have a domain).

@dejardine
Copy link

Running into the exact same problem with cosmicjs.

@luqven
Copy link
Contributor

luqven commented Jul 8, 2021

Hey @719media and @dejardine

We just released v2.9.0, which should address this issue. You can now pass full URLs to the src attribute.

So that, even if you have a different domain option defined in your App.vue:

import Vue from 'vue';
import VueImgix from 'vue-imgix';

Vue.use(VueImgix, {
  domain: "<your company's imgix domain>",
  defaultIxParams: {
    // This enables the auto format imgix parameter by default for all images, which we recommend to reduce image size, but you might choose to turn this off.
    auto: 'format',
  },
});

You can still use a full URL as the src attribute value.

<ix-img src="https://sdk-test.imgix.net/amsterdam.jpg" sizes="100vw" />

This of course can be done side-by-side with images that do use the domain configuration.

<template>
  <div>
    <h2>Full URL API Example</h2>
    <!-- this image will use the domain configured on the plugin -->
    <ix-img src="/examples/pione.jpg" width="100" data-testid="full-url-api" />
    <!-- these images will use the domain contained in the src -->
    <ix-img
      src="https://assets.imgix.net/examples/pione.jpg"
      width="100"
      data-testid="full-url-api"
    />
    <ix-img
      src="https://sdk-test.imgix.net/amsterdam.jpg"
      width="100"
      data-testid="full-url-api"
    />
  </div>
</template>

<script>
export default {
  name: 'full-url-api',
};
</script>

Thanks again for taking the time to report this issue and please feel free to open it again if there's anything we missed.

@luqven luqven closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants