Skip to content

Raw param has no effect with custom Param Type #178

Closed
@bouncehead13

Description

@bouncehead13

Version: 5.0.18
Platform: Running with Angular (5.x)

Problem: I created a custom ParamType for many reasons, one being so that I didn't have to declare raw: true in so many places throughout our code. However, I am noticing the raw parameter is not carrying through to the Param itself.

{
  encode: ....,
  decode: ....,
  ...
  raw: true
}

This line of code shows that raw can be set from either the config or the type itself. However, from a few lines right above, I determined the type is getting reassigned. Within that logic it creates an ArrayType and the type's original value is never copied over.

Solution: I think it's just as simply as adding type.raw when creating an ArrayType as such. Code below copied and modified slightly from the source.

extend(this, {
  dynamic: type.dynamic,
  raw: type.raw    <----- add this
  name: type.name,
  pattern: type.pattern,
  inherit: type.inherit,
  is: arrayHandler(type.is.bind(type), true),
  $arrayMode: mode,
});

Without this fix, it simply just means every config needs to manually define the raw config param. Workaround, but not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions