johanhelsing / bevy_web_asset

Bevy asset loader that transparently supports loading over http(s)
Apache License 2.0
71 stars 17 forks source link

Trouble loading assets from localhost while doing development #25

Closed sbesh91 closed 7 months ago

sbesh91 commented 7 months ago

I've been working with this library using an image pulled from S3 as a testing URL.

This image parses in just fine, but I'm running into an asset path parsing error when sending in a url that contains a port.

Ideally, I'd like to use pre-signed urls from S3 and that would look something like this.

The error I'm seeing so far looks like this.

/bevy_asset-0.12.1/src/path.rs:104:37: called `Result::unwrap()` on an `Err` value: InvalidSourceSyntax

I tracked down where I think this is being thrown to the while loop that parses paths looking for :. Since there is a second : in the url containing a path, it seems to throw that InvalidSourceSyntax error.

    while let Some((index, char)) = chars.next() {
          match char {
              ':' => {
                  let (_, char) = chars
                      .next()
                      .ok_or(ParseAssetPathError::InvalidSourceSyntax)?;
                  if char != '/' {
                      return Err(ParseAssetPathError::InvalidSourceSyntax);
                  }
                  let (index, char) = chars
                      .next()
                      .ok_or(ParseAssetPathError::InvalidSourceSyntax)?;
                  if char != '/' {
                      return Err(ParseAssetPathError::InvalidSourceSyntax);
                  }
                  source_range = Some(0..index - 2);
                  path_range.start = index + 1;
              }
              '#' => {
                  path_range.end = index;
                  label_range = Some(index + 1..asset_path.len());
                  break;
              }
              _ => {}
          }
      }
sbesh91 commented 7 months ago

Moved to bevy repo https://github.com/bevyengine/bevy/issues/11533